Live data from Hacker News

Ten Years of TypeScript

devblogs.microsoft.com

101–110 of 147 posts

Re: Ten Years of TypeScript

#101

Earlier quoted context omitted.

The real genius of it is that it's really not a "type" system at all: it's a contract system. The nearest thing like it was Eiffel. The new "satisfies" feature in 4.9 makes this even more clear. Honestly there's so much space to cover here, I think it's just going to keep getting better and better.

I’m curious what you’re distinguishing here. To me a type system and a contract system are identical concepts with different descriptions. It seems like you might be highlighting the structural typing aspects of TypeScript’s type system versus nominal or concrete types in many others, but that’s been clear for most TS usage for since well before `satisfies` so I’m not sure if my interpretation is right.

For a start:

https://en.m.wikipedia.org/wiki/Design_by_contract

Re: Ten Years of TypeScript

#102
post #48
post #32

I like the idea of typescript. I tried to port a vanilla js browser game to typescript and I found it introduced a lot of complexity to the project. It sucked me into the npm ecosystem and forced me to rewrite every file to use js modules import/export syntax and a bundler like webpack to resolve all the modules business for browsers when none of those were needed before. Of course I could set TS modules to none but…

If I understand correctly, before moving to TS / npm, you would concatenate your library files and your own code, and in your own code reference libraries using some kind of global variable à la `$.` for jquery? If that's the case, you could add the libraries .d.ts to your project and augment the global.Window interface with types pulled from those definitions. You would then be able to call `window.something` and ha…

Yes, that's exactly right. I just include pixi.min.js which exposes the "PIXI" global variable.

> If that's the case, you could add the libraries .d.ts to your project and augment the global.Window interface

Do you know where I can find an example of this? I've been able to do "npm install pixi.js", which gives me access to the .d.ts file but I'm not sure how to then map those types to the global PIXI object exposed by pixi.min.js without turning everything into a module and doing an "import PIXI" from node_modules of some flavor or another.

> Which bundler are you using? If you don't need any of the advanced webpack / rollup stuff, have you tried a fast one like esbuild?

My bundler is literally "cat *.js > bundle.js" which works well. I have not tried esbuild, though I've read good things about it. I'm sort of gunshy about learning new js tooling like this though ever since I learned grunt and then gulp once upon a time....

Re: Ten Years of TypeScript

#103
post #98

Earlier quoted context omitted.

It’s my impression GP doesn’t have a clear picture of where TypeScript ends and the rest of the tooling ecosystem begins. Which is totally understandable, especially given how pervasive TypeScript is and how it nearly totally overlaps with the rest. I think you and I have similar perspectives on the details, but you could be kinder expressing them.

I assumed repox prefers bluntness, due to their writing style. I was careful with the words and tone that I chose. Checking comment history, repox wrote that they are a Dane (which I didn't know). My experience of friends from other nearby countries is that their style of interaction can be seen as rude by many people. In particular my stereotype is that Americans often prefer a more gentle approach. I think you are…

Hey, I mistake appropriateness of being blunt too. I’m autistic, so. I’m kind of impressed you dug through my recent comment history, even if the quote feels misplaced. Anyway feel free to be blunt with me, if you recognize me around.

But I’ll also be blunt when I notice a critique is probably misplaced.

Re: Ten Years of TypeScript

#104

Earlier quoted context omitted.

I agree that the typescript team should consider using the compiler to extend javascript rather than just supplement it with types. Like you said, there are technically parts of typescript that don't have a direct corollary in js (enums/namespaces), so why not take it a step further and add some of the features that js is missing? The only example where they've really taken that next step is with experimental decorat…

The article explains their stance on adding runtime features.

I read it, and I empathize with their stance. I'm actually torn between wanting Typescript to be as compatible with Javascript as possible, and wishing we didn't have to wait for TC39's process to play out before using new features (which I've written about before on hn[1]). Given their design goals though, the Typescript team has done a great job.

[1] https://news.ycombinator.com/item?id=32188944

Re: Ten Years of TypeScript

#105

Earlier quoted context omitted.

Typescript by itself is just the language. You could try a different typescript compiler like esbuild for example.

> However, esbuild does not do any type checking so you will still need to run tsc -noEmit in parallel with esbuild to check types.

Your IDE can be doing type checks on whatever file(s) you're working on, you can use esbuild or swc to compile to javascript to make sure it runs correctly, and you can periodically use tsc to fully compile and typecheck your entire codebase to catch anything that you somehow missed in the IDE.

Re: Ten Years of TypeScript

#106
post #20

This seems like a great time to announce my successor to CoffeeScript: Civet, a language that transpiles to TypeScript. https://github.com/DanielXMoore/Civet

Very cool! For years I've wanted to fork LiveScript and integrate it with the TS checker somehow (and remove `on/off/yes/no`, good call), sort of an F# to TypeScript's C#

Re: Ten Years of TypeScript

#107
Someone please point me to a project using TypeScript that isn't an over-engineered steaming pile of excrement. Please. Enlighten me. I've yet to see one where the code is even somewhat mentally parsable. Abstractions galore, needless separations of concern, indecipherable build scripts that take forever to run, insane JS output and more. It's basically a write-only language extension where only the people actively working on a project can actually understand any of it.

Look at this thread. So many comments about how great the language is, but with the caveat about how horrible the ecosystem is. Think about that for a second and maybe you'll get it.

What is it about strongly typed languages that attracts developers enamored with their own cleverness? I'd rather work with Java. And I loathe Java.

Re: Ten Years of TypeScript

#108
post #20

This seems like a great time to announce my successor to CoffeeScript: Civet, a language that transpiles to TypeScript. https://github.com/DanielXMoore/Civet

Just have to say thank you so much for CoffeeScript! It was pivotal in my career and has brought me a lot of joy :)

Re: Ten Years of TypeScript

#109
Reading this thread gave me my first encounter with `satisfies`. While I love the concept, the syntax really bothers me. I'm used to seeing the type right after the variable name when it's being defined, not looking after the assignment for it. The placement after assignment almost seems to imply that if you `let x = 1 satisfies number` with an implicit "any" you could reassign x and have it satisfy something else further on in the code, which would be an unbelievably terrible antipattern. (I'm assuming you can't do that?)

To me it seems more logical to use something like a double-colon or some other syntactic sugar to imply `satisfies` when you declare a variable... and possibly a or just prepend for casting.

Re: Ten Years of TypeScript

#110
post #98

Earlier quoted context omitted.

I assumed repox prefers bluntness, due to their writing style. I was careful with the words and tone that I chose. Checking comment history, repox wrote that they are a Dane (which I didn't know). My experience of friends from other nearby countries is that their style of interaction can be seen as rude by many people. In particular my stereotype is that Americans often prefer a more gentle approach. I think you are…

Hey, I mistake appropriateness of being blunt too. I’m autistic, so. I’m kind of impressed you dug through my recent comment history, even if the quote feels misplaced. Anyway feel free to be blunt with me, if you recognize me around. But I’ll also be blunt when I notice a critique is probably misplaced.

All good.

To explain: I quickly scanned some of their recent comments to see if my assumptions could be wrong. When I noticed they were Danish, I then wondered if you were American, so I used hn.algolia.com to scan your comments for “American” as a keyword. You said you were, but at that point I luckily noticed the comment of yours that I quoted, which I just couldn’t resist cheekily passing back to you, because it fitted the discussion on comment quality at a meta level.

I often write personal notes like this after the topic has dropped from the front page. If there are a lot of people still reading the comment threads, I try harder to not be a distraction to others and I try to keep on topic.

I really do appreciate your effort to keep my comment quality high - if we all do that for many comments (especially through voting) then the whole community benefits. I don’t realise when I get tone wrong. In this case I have been very slightly downvoted on both comments which is not usual for me - so your comment was an extra help.

Post reply on HN