What is Typescript ?
TypeScript is an open-source language which builds on JavaScript, one of the world’s most used tools, by adding static type definitions.
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript is pure object oriented with classes, interfaces and statically typed like C# or Java.
Advantages of Typescript
- Code easier to understand
- Code easier to refactor
- Code easier and faster to implement
- Less tests : Less tests means shorter time to develop new features, and a smaller codebase, which in turn is less complicated, less error-prone and easier to maintain.
- Code easier to merge
Disadvantages of Typescript
- Developers mastering C#, C++ or Java often argue that TypeScript is not a true statically typing language.
- Transpiling :
Browsers can’t interpret the TypeScript code, so you need to transpile it to JavaScript before running. However, this process is highly automated and doesn’t require a lot of additional time. In total, the downside of this step is far less significant than its benefits: The compiler spots flaws and flags them before they can cause any damage.
Alternatives to Typescript
CoffeeScript
CoffeeScript is a lightweight language based on Ruby and Python which transcompiles (compiles from one source language to another) into JavaScript. It provides better syntax avoiding the quirky parts of JavaScript, still retaining the flexibility and beauty of the language.
Dart
Dart is a programming language designed for client development, such as for the web and mobile apps.
It is developed by Google and can also used to build server and desktop applications. Dart is an object-oriented, class-based, garbage-collected language with C-style syntax.
Dart can compile to either native code or JavaScript. It supports interfaces, mixins, abstract classes, reified generics, and type inference.
Kotlin
Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference.
Kotlin is designed to interoperate fully with Java, and the JVM version of its standard library depends on the Java Class Library, but type inference allows its syntax to be more concise.
Kotlin mainly targets the JVM but also compiles to JavaScript or native code. Kotlin is sponsored by JetBrains and Google, through the Kotlin Foundation.
Babel
The Babel ecosystem is very rich, and there are many useful Babel plugins. When using TypeScript you can’t use that ecosystem.
idx: Transpile the idx function to efficient code styled-jsx: Transpile scoped CSS from JSX components react-intl: Extract text for translation