Live data from Hacker News

TypeScript is now officially 10 years old

coderoasis.com

61–70 of 207 posts

Re: TypeScript is now officially 10 years old

#61
post #9

>TypeScript never set out to build a separate, distinct, and prescriptive language. Instead, TypeScript had to be descriptive. Sadly, the majority of people writing Typescript rarely care about descriptive and readable code these days. Somehow the focus shifted from using types to better understand complex systems through the code itself , to writing whatever polymorphic union type abomination that yields the best In…

The polymorphic union type abominations are precisely because TypeScript is insistent on being a thin layer on top of JS.

In particular there is no built-in ADT syntax, but the type system does support ADTs using the aforementioned polymorphic union abominations, so it is possible yet tedious to write them.

They are in a tricky situation because TC39 really does not care about TypeScript at all when introducing new features into JS. So TypeScript is doing its best to avoid breaking future compatibility with a standard they have no control over. Sometimes this makes the language worse, but they are playing the long game.

Re: TypeScript is now officially 10 years old

#64
post #37

Typescript was my stepping stone into the world of Rust. Even before Deno made it easy, it was straightforward enough to configure a simple tsconfig and just run tsc. Much like cargo, there is a lot to be said for "it just works" tooling - especially for beginners or even new programmers. It is probably fair to say it is one of the most influential and impactful languages of all time. There's even the future possibil…

Opposite experience. Rust was my stepping stone into "hey, maybe JS will be better with some degree of static typing?" Yes it would. But not the way TypeScript does it though, and there aren't any other viable options, are there? TypeScript brands itself a "superset" of JavaScript. In practice, it arbitrarily invalidates completely sensible JavaScript idioms.

> In practice, it arbitrarily invalidates completely sensible JavaScript idioms.

Such as?

Re: TypeScript is now officially 10 years old

#65

Earlier quoted context omitted.

Also the `any` type [1]. It makes porting an existing project ridiculously easy: just type everything as `any`, and it also gives freedom to the developer to think in code when developing, trusting that they (will) know what they are doing, instead of screaming at the smallest mis-type with annoying bright red squiggly lines. It is so liberating to type a variable as `any` when sketching new code, figuring things out…

And then you have to contribute to a codebase with restrictive ESLint (bleurgh!) configuration, so you can't even try out whether your code works because the tooling disallows you from compiling it as long as it contains "any", and the other devs are like "but muh best practices". So not only you gotta work around TS, you gotta do it invisibly . How did people even live before VSCode's type hint popups covered up the…

> How did people even live before VSCode's type hint popups covered up the previous line?

Same. Like normal people do when they use Visual Studio/IntelliJ/QTCreator

Re: TypeScript is now officially 10 years old

#66
post #40
post #37

Typescript was my stepping stone into the world of Rust. Even before Deno made it easy, it was straightforward enough to configure a simple tsconfig and just run tsc. Much like cargo, there is a lot to be said for "it just works" tooling - especially for beginners or even new programmers. It is probably fair to say it is one of the most influential and impactful languages of all time. There's even the future possibil…

> There's even the future possibility of much of its type syntax being absorbed back into JavaScript: https://github.com/tc39/proposal-type-annotations ... as comments. Which superficially resemble the syntax of type hints but do nothing. Which has to be one of the worst language design decisions of all time.

I'd disagree that its a poor decision, some help is better than no help when reading code - and if it's inline then it's intrinsically meaningful.

By no means is it perfect, the language doesn't enforce the type rules, but that the developer has the option is far better than not. As far as I can tell the proposal would pretty similar to Python; one can misleadingly or accidentally misuse type hints like the following:

  def myfn(a: int) -> str:
    return int(a)
  
  print(myfn("42"))
But when done right, it gives you a leg up when you come back to read your own code or scan over someone else's. When you're reading over other's code in group programming assignments, comments make a world of difference (a niche example).

It is a choice, but its use in code might just inspire someone to investigate further - my own introduction to types in programming came when I wondered what these oddly placed colons and arrows were in some Python I came across. If they do add these annotations to JavaScript, some future programmer browsing the source of a web page may well just stumble upon types and have a whole new world of theory opened up to them - I'm all for it.

Re: TypeScript is now officially 10 years old

#67
post #11

Earlier quoted context omitted.

In my opinion the most important factor was that it is a superset of JS and any valid Javascript code is/was valid TS code. That allowed for gradual adoption and you didn't have to risk going all-in into new technology.

TS is emphatically not a superset of JS. It rejects perfectly valid JS leaving you no recourse other than design your whole architecture around what TypeScript allows. Which is what Microsoft wants of course.

That’s not true. You can import JS directly into TS or use ts-ignore annotations.

Re: TypeScript is now officially 10 years old

#68

Earlier quoted context omitted.

Also the `any` type [1]. It makes porting an existing project ridiculously easy: just type everything as `any`, and it also gives freedom to the developer to think in code when developing, trusting that they (will) know what they are doing, instead of screaming at the smallest mis-type with annoying bright red squiggly lines. It is so liberating to type a variable as `any` when sketching new code, figuring things out…

And then you have to contribute to a codebase with restrictive ESLint (bleurgh!) configuration, so you can't even try out whether your code works because the tooling disallows you from compiling it as long as it contains "any", and the other devs are like "but muh best practices". So not only you gotta work around TS, you gotta do it invisibly . How did people even live before VSCode's type hint popups covered up the…

This comment has just triggered my PTSD from every Typescript project I've had to work on.

Re: TypeScript is now officially 10 years old

#69

Earlier quoted context omitted.

And then you have to contribute to a codebase with restrictive ESLint (bleurgh!) configuration, so you can't even try out whether your code works because the tooling disallows you from compiling it as long as it contains "any", and the other devs are like "but muh best practices". So not only you gotta work around TS, you gotta do it invisibly . How did people even live before VSCode's type hint popups covered up the…

> How did people even live before VSCode's type hint popups covered up the previous line? Same. Like normal people do when they use Visual Studio/IntelliJ/QTCreator

I.e. cringing all the time?

Re: TypeScript is now officially 10 years old

#70

Earlier quoted context omitted.

Opposite experience. Rust was my stepping stone into "hey, maybe JS will be better with some degree of static typing?" Yes it would. But not the way TypeScript does it though, and there aren't any other viable options, are there? TypeScript brands itself a "superset" of JavaScript. In practice, it arbitrarily invalidates completely sensible JavaScript idioms.

> In practice, it arbitrarily invalidates completely sensible JavaScript idioms. Such as?

[deleted]
Post reply on HN