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

  • Jimbabwe
    link
    fedilink
    English
    arrow-up
    13
    ·
    1 year ago

    Typescript is Javascript with extra rules added to keep you, the developer, honest and explicit. The main way it does this is by enforcing types. This is a whole subject in and of itself, so here’s a lazy hand-wavy example from an internet stranger:

    // regular js You, the developer: “hey js compiler, I’m gonna make a new array” JS compiler: “Cool, dude!” You: “Now please push ‘cat’, 5, NaN, and Date.new() onto the array” JS compiler: “No problem my guy (or girl)! You probably know what you’re doing!”

    // typescript You, the developer: “hey js compiler, I’m gonna make a new array” Typescript: WHAT. THE. FUCK. Just like that?? An array of what, exactly?! Do you even know?? You’re grounded, mister. Don’t ever try to pull that shit again. The FUCKING nerve.”

    Basically you and the compiler are co-parenting a removed js baby and you can pick between deadbeat dad or helicopter Karen mom.