this post was submitted on 15 Aug 2023
13 points (93.3% liked)

No Stupid Questions (Developer Edition)

930 readers
1 users here now

This is a place where you can ask any programming / topic related to the instance questions you want!

For a more general version of this concept check out !nostupidquestions@lemmy.world

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

Do I master Typescript if I master Javascript ? Is Typescript syntax different ? Answers appreciated, thank you !

you are viewing a single comment's thread
view the rest of the comments
[–] ShortFuse@lemmy.world 3 points 1 year ago

Typescript is 3 things:

  • A language that you can write code in that compiles down to JavaScript. It's 99% JavaScript, though there are custom things.
  • A type syntax system that can define object schemas.
  • A type checker system for both JavaScript and Typescript files.

Generally, people use all three at once (.ts files), but you don't have to. Types aren't runtime code and can be mixed into the same file you are working on, even inline. Or you can use a separate d.ts file. Or you can use JSDocs.

You can also ask the Typescript checker (bundled with the compiler) to perform type checking on your .js or .ts with a slew of custom options. Commonly, when working with .ts, if the type checker fails against the ruleset, it won't continue on to transcompiling to .js.