5 ms·
Two of the links you listed have pretty good reasons: The creator of uhtml believes there are transpilation bugs. I can't say whether this is true, but if it's
by schwartzworld 4y ago
Two of the links you listed have pretty good reasons:
The creator of uhtml believes there are transpilation bugs. I can't say whether this is true, but if it's an issue for them, I guess that's a valid reason.
Jason Miller's tweet also includes a common reason: he isn't good at it and doesn't understand it, or in his words "the amount of time I have to spend screwing up my already-working code to make TypeScript happy". This is a big one. TypeScript is hard, and poorly written TypeScript increases complexity. My last job was a TS codebase written by people who didn't understand it and it was a major impediment to productivity.
The Rich Harris tweet represents a common misunderstanding about TypeScript types. If your types can be represented by primitives like `string` or `number`, then his JSDoc approach is fine, but when writing TS those sorts of primitives are barely scratching the surface. For example, TS has a powerful Generics syntax that cannot be duplicated in a code comment.
TypeScript is very complex because it needs to be able to type all valid JS code, which means being able to describe things that most other languages would never even allow. JavaScript is very flexible and permissive, and all of us are used to working with them in a way that's hard to type. One of the first steps in learning TS is to change the way you write code to make it easier to type. You have to make decisions earlier in the process, and yes, there is usually more time spent writing code initially, but if done well, you can screen out a lot of bugs.
IMO these devs have the luxury of not using TS because they can expect the community to provide the types for them.
- Existenceblinks 4y ago> One of the first steps in learning TS is to change the way you write code to make it easier to type. I think this is a correct answer. TS is just a different language happened to interop js easier than the others.
- throwaay2322u43 4y ago> TS has a powerful Generics syntax that cannot be duplicated in a code comment. This is false though, but admittedly not documented well.
- schwartzworld 4y agoHow can a comment provide useful generics? I'm genuinely curious.
- sarahdellysse 4y agoSo say we had code like this: const safeSplice = (items, start, deleteCount, ...itemsToAdd) => { const copy = [...items]; const deleted = copy.splice(start, deleteCount, ...itemsToAdd); return { deleted, list: copy, }; }; We could put this as a jsdoc-style typescript comment just before the `const safeSplice` line: /** @type {<Item>(items: Array<Item>, start: number, deleteCount?: number, itemsToAdd?: Array<Item>) => { deleted: Array<Item>, list: Array<Item> }} */ or as a multi-line type declaration: /** @type {<Item>( * items: Array<Item>, * start: number, * deleteCount?: number, * itemsToAdd?: Array<Item> * ) => { * deleted: Array<Item>, * list: Array<Item> * }} */ Alternatively, you could do something like this in place of the above: /* * @template Item * @param {Array<Item>} items * @param {number} start * @param {number} [deleteCount] * @param {Array<Item>} itemsToAdd */ I started out doing the former because I liked using the typescript notation, but I ended up doing the latter more often as I could leave the return type off the signature, which I prefer to do
- FractalHQ 4y agoThis is really cool! TIL. At this point though, I feel like you might as well just use Typescript, no? You’ll get more features / tooling and cleaner syntax. I’m intrigued to learn more about advanced JSDoc now though, if anything to be more prepared if I’m ever forced to work with it in the future.
- arriu 4y agoFully agree. Additionally, many of these devs are arguably masters at vanilla JavaScript. Some learned JS before modern features became available. They probably don’t need ES5 features to be productive, let alone the newer features or for that matter TypeScript. The frustration is that they would probably benefit from using TypeScript in the long run.
- enduser 4y agoI agree. I am a going-greybeard who plateaued at one point in the IE5/6 era building ambitious cross-browser apps using direct-DOM vanilla JavaScript. I resisted learning TypeScript because it felt like coding with handcuffs on. I was sold on it when I realized how much easier the handcuffs make it to accept code contributions. I've internalized TS enough that I still get to flow state on my own code. Whole categories of rookie mistakes no longer interrupt my blissful concentration, because they are caught by tooling before making it in to a pull request.
- FractalHQ 4y agoThanks for saying this.. I use TS religiously and haven’t been able to go back since diving in, but man is complex Typescript hard! I’m building a DAW right now with pretty large interconnected, dynamic systems and the TS is getting really mind bending with all of the layers of inheritance and generics. A functional architecture as opposed to this OOP one would probably make life easier… but those decisions were mostly out of my control early on. That being said, as a Svelte user, I really wish Rich would stop dragging his feet on Typescript as much as he does (no TS in markup is a huge bummer). I can’t complain too much though.. the Svelte Compiler is a magnificent beast and I couldn’t write it let alone contribute to it in a meaningful way. If leaving Typescript to the other maintainers helps him be more productive, so be it.
- marshmellman 4y agoA DAW in TypeScript? How can I learn more about this?
- FractalHQ 4y agoIt’s currently private unfortunately but the client is considering open sourcing it once were done using it in a few upcoming projects! Will ping you when that happens.
- marshmellman 4y agoNice, that would be great!