DEV Community

Discussion on: Explain Typescript, I'm Like Five

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

TypeScript is just some tidbits that can be transformed to JavaScript, as well as allows you to write JavaScript directly inside it.

Some benefits of using TypeScript are

  • Better typing (albeit superficial and IDE only; nothing persists at runtime; actually TypeScript maintainers reject the idea of having it at runtime)
  • Better IDE integration, especially in Visual Studio Code

I would disagree that TypeScript is not really a strongly typed language; but more of an IDE-oriented language, but it is as dynamically typed as JavaScript at runtime. Or like a static type-checker, e.g. Flow; which is nothing new.

Furthermore, you can use some TypeScript features inside JavaScript, even if you don't use *.ts extension, by adding // @ts-check at the top of the file, and use VSCode IDE. You can use interfaces in pure JavaScript as well, by using JSDoc's @typedef.

If you want a strongly-typed compiled-to-JavaScript language, example includes Kotlin/JavaScript, but it will not allow you to write JavaScript inside it. (and the compiler is painfully slow.)

Another dimension that TypeScript probably doesn't always do includes newer ECMAScript features. In this case, you might use Babel. And sometimes, you would want to use BOTH TypeScript and Babel together. (In reality, TypeScript compiler can indeed replace some parts of Babel, such as compiling to ES5.)

Collapse
 
sasicodes profile image
Sasidharan

Great summary.Im 15 now ;)