Typescript is a typed superset of Javascript that compiles to plain JavaScript. TypeScript is an open-source object-oriented language maintained by Microsoft. Due to the static typing in TS, code written in TypeScript is more predictable and is generally easier to debug then normal JS.
TypeScript has one extra compilation step to JavaScript that catches all kinds of errors before they reach runtime and break something in the code.
TypeScript is a typed superset of JavaScript” but it assumes you know what a “superset” is and what “typed” means. Instead, to keep things simple you can think of TypeScript as of “a layer on top” of JavaScript.
TypeScript is a layer because you can write TypeScript code in your editor. After a compilation, all that TypeScript stuff is gone and you’re left with plain, simple JavaScript.
If the idea of the compilation step confuses you keep in mind that JavaScript is already compiled and then interpreted. There is a JavaScript engine that reads and executes your code.
JavaScript engines are not able to read TypeScript code so any TypeScript file should go under the “pre-translation” process, called compilation.
#typescript #javascript #ts #js