this post was submitted on 08 Oct 2023
28 points (73.3% liked)

Programming

17418 readers
30 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

Specifically, do you worry that Microsoft is going to eventually do the Microsoft thing and horribly fuck it up for everyone? I've really grown to appreciate the language itself, but I'm wary of it getting too ingrained at work only to have the rug pulled out from under us when it's become hard to back out.

Edit: not really "pulling the rug", but, you know, doing the Microsoft classic.

you are viewing a single comment's thread
view the rest of the comments
[–] FooBarrington@lemmy.world 8 points 1 year ago (2 children)

In TypeScript, it fails. You can't treat an object as an arbitrary key/value pair. That's a good thing... but still, it means TypeScript is not a superset of JavaScript.

No, it doesn't fail. It compiles to perfectly valid JS that runs exactly as you'd expect. The type checking itself errors, because you've made an error - but the compilation isn't prevented by this error.

So yes, Typescript is a superset of JavaScript.

[–] jeffhykin@lemm.ee 1 points 1 year ago* (last edited 1 year ago) (1 children)

That is an important difference. Still lots of people, myself included, classify "compiler printing an error (not a warning)" as failure, even if bizzarly the code still runs somehow.

[–] FooBarrington@lemmy.world 1 points 1 year ago

That's because you're missing the distinction between compiler and type checker. The compiler doesn't check types, it strips them. The type checker only checks types, it doesn't compile. They are often used in conjunction, though increasingly the compilation is done by e.g. esbuild.

But there is nothing "bizarre" about the code running, since literally, TS is a superset of JS.

[–] lorty@lemmy.ml 1 points 1 year ago (1 children)

Wouldn't it fail in strict mode?

[–] FooBarrington@lemmy.world 1 points 1 year ago

The type checking does, but not the compilation.