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

Programming

17028 readers
98 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
[–] Kalabasa@programming.dev 6 points 11 months ago (9 children)

What are the additional requirements? Afaik valid JS is valid TS.

[–] abhibeckert@lemmy.world 2 points 11 months ago* (last edited 11 months ago) (7 children)
var foo = {};
foo.bar = 42;

Perfectly valid, and extremely commonly used, coding pattern in JavaScript - it's essentially the normal way to do an associative array or hashmap in JavaScript. It's also one of the commonly used ways to (poorly) simulate OOP in JavaScript.

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.

AFAIK that source code will be accepted by the TypeScript compiler if the file has a *.js extension, but that's an ugly workaround and it also means you can't copy/paste code between files. You have to rewrite the code.

[–] themusicman@lemmy.world 2 points 11 months ago (1 children)

Doesn't change the fact that you can strip types and get js

[–] lolcabanon@programming.dev 1 points 11 months ago

I know a cool library you can use to convert .ts files in Js! It's called tsc!

/s

load more comments (5 replies)
load more comments (6 replies)