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

  • ShortFuse@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    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.