Basics of Typescript and best practices
What is Typescript?
How to get started
Typescript best practices
- Take advantage of typing. Strict typing is really one of the major reasons to use TypeScript, so if you aren’t going to use it, you probably don’t need to be using TypeScript. Assess whether TypeScript is necessary for a project before starting it.
- Defer to the script itself. If possible, let the script determine the type for any object. The script is going to be able to analyze which typing is best within the code, which also takes cognitive load off the programmer.
- Don’t use parameter properties in class constructors. Parameter properties can become confusing especially for those who are using TypeScript for the first time; it’s best to avoid this entirely.
- Don’t use require to import modules. Require is no longer necessary for importing modules; instead, importing can be done directly.
Subscribe to our Newsletter
Stay up-to-date with the latest big data news.