this post was submitted on 08 Sep 2023
530 points (94.0% liked)

Programmer Humor

19623 readers
6 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 14 points 1 year ago (2 children)

I don't think it really fractures anything considering you can call a ts package from js without knowing. The other way also works with third party typings in DefinitelyTyped.

It really just adds a bit of extra type info into js, looks like js, and transpiles into js that looks almost exactly like the input, including comments and spacing and such if you like, so there isn't any lockin.

There isn't any competition, it's just an extra optional tool for the js ecosystem in my eyes.

[–] [email protected] 1 points 1 year ago (1 children)

The transpilation that typescript does doesn't really have anything to do with typescript, it's just there because typescript wants to support the latest ecmascript features, so transpilation is necessary for that, but technically you could simply strip out the type info and have another transpiler like babel handle the backwards compatibility. I think there are a few minor exceptions to that, like enums. There was even a proposal to add some typescript types to native JavaScript that would be ignored by the interpreter and just act as comments.

[–] [email protected] 1 points 1 year ago (1 children)

I mean, tsc without any of the backporting functionality is still a transpiler since it goes from a high level language(ts) to another high level language(js). Transpilation as a concept doesn't imply that it is for backporting language features or that the source and destination languages are the same, just that it is a transformation from source code to a similar or higher abstraction level language source code

[–] [email protected] 2 points 1 year ago

Yes, it's still a transpiler, I'm not saying it isn't, but what I mean is that it doesn't add any functionally specific to the typescript language. There's a transpiler for TS that doesn't even do any type checking at all and just does the type stripping and back porting. But of course, that's not why people use typescript. All the features that are actually important to typescript could be done through a linter instead. If type annotations were added to JavaScript you could get most of typescript's features with linting rules and just handle back porting in a more standard way.

[–] [email protected] -1 points 1 year ago

I think too many people ITT are conflating Typescript with Typescript frameworks like Angular.