3 ms·
It feels like the same information is repeated often 2, sometimes even 3 times. And overall, I don't think this book has anything more than what's already in of
by golergka 3y ago
It feels like the same information is repeated often 2, sometimes even 3 times. And overall, I don't think this book has anything more than what's already in official docs.
- tough 3y agoI thought it was this official "Handbook" https://www.typescriptlang.org/docs/handbook/intro.html https://www.typescriptlang.org/docs/handbook/intro.html
- eBombzor 3y agoThere's also this one (not official) https://basarat.gitbook.io/typescript/ https://basarat.gitbook.io/typescript/
- graypegg 3y agoI would actually love a “Typescript: The good parts” as a spiritual sequel to Javascript: The good parts. [0] Something that starts at the basics and builds upon that knowledge layer by layer like this handbook, but doesn’t dedicate more than a page to any one topic, and doesn’t repeat itself. Not a tutorial, but more like a glossary ordered by abstraction. Plus, there’s a lot of Typescript I would consider not part of the “good stuff”, we can leave out enums. [0] https://www.goodreads.com/book/show/2998152-javascript https://www.goodreads.com/book/show/2998152-javascript
- HWR_14 3y agoWhat's wrong with enums? Enum types in general are very useful.
- tough 3y agoSomeone mentioned they shouldn't be in TS altogether in another thread shrugs I like em too
- triyambakam 3y agoIf you mean traditional enums, called unions in Typescript and represented by the pipe symbol, then nothing. But if you mean the named Enum keyword in Typescript, then the problem is that they emit runtime code and aren't type safe.
- mostlylurks 3y ago> What's wrong with enums? They don't compile down to just the same code with the type annotations and definitions removed, which is often considered to be the ideal that typescript should follow. Instead, they compile down to some more complicated blob of javascript. People critique and avoid typescript's namespaces for the same reason. > Enum types in general are very useful. You can use unions for the same purpose without the aforementioned drawback, and unions have other benefits which typescript's enums don't offer, like support for more complex data types, which makes unions closer to set of features more modern languages tend to offer via enums, while making enums closer to the barebones enums found in languages like C and C++ (effectively just a set of named constants enclosed into a type).
- HWR_14 3y agoI guess I don't value the "TS transpiles to JS 1-to-1" property very much. Unions are useful for quite a few things. But I literally was talking about the barebones (and thus simple to write) C/C++ style enums. Where I know it can be one of several primitive values and not have to spend the time creating a class for each possible value.
- jahewson 3y agoAmongst their issues is the issue of enum vs const enum. These compile to different outputs and support different behaviors. It’s not possible to compile a TS file that uses them without looking at the enum declaration to see if it’s const. It’s no longer possible to strip the types and have something that any JS bundler can understand.
- HWR_14 3y agoThat seems like a limitation that makes sense. A non-const enum would need a lot more complexity to be extensible at runtime.
- chrisweekly 3y agoTry Dan Vanderkam's "Effective Typescript: 62 Specific Ways to Improve YourTypeScript" (O'Reilly). I'm no TS guru, but IMHO it's pretty well-grounded in first principles.
- orta 3y agoPerhaps it is LLM generated, as git says it is ~3 months old - but it links to a page on the TypeScript website which was removed a long time before that, https://www.typescriptlang.org/dt/search https://www.typescriptlang.org/dt/search
- fullstackchris 3y agoyeah I took a look and couldnt help but feeling like it was a laundry list with minimal examples and not always telling you why or when you would use a certain feature of TypeScript. Example: TypeScript _does_ enable you to overload functions, but overloading functions is nearly never the best way to do something, often cited as a spaghetti code pattern