ARTICLEViews: 58Share  Posted by - Anonymous

typescript tips

Type-only imports and exports is supported from Typescript 3.8.0.

Set Typescript version >= 3.8.0 to resolve this error.


Here are some TypeScript tips that may help you:

  1. Use the strict compiler option - This enables strict type checking, which helps catch errors at compile time rather than at runtime.
  2. Use interfaces and types to define your data structures - Interfaces and types help ensure that your data is consistent and correctly typed throughout your application.
  3. Use readonly modifier - This allows you to make properties and arrays immutable, which can help prevent accidental modifications to your data.
  4. Use as const to make literals immutable - This tells TypeScript that a value is a literal and should not be changed.
  5. Use optional chaining ?. - This helps prevent errors when accessing nested properties or methods on objects that may be undefined or null.
  6. Use the never type - This type indicates that a function will never return and can help catch errors in your code.
  7. Use union and intersection types - These types allow you to combine types in various ways to create complex data structures.
  8. Use generics - Generics allow you to write reusable code that can work with different types.
  9. Use type guards - Type guards help you check the type of a variable at runtime and perform different actions based on the type.
  10. Use --watch mode - This enables TypeScript to recompile your code whenever you make changes, which can help speed up your development process.

Overall, TypeScript is a powerful tool that can help you catch errors early and write more maintainable code. By following these tips, you can get the most out of TypeScript and build better applications.


If you're a Typescript Developer and you use it pretty much for any project you would work on, then, you're probably missing out ...

This saved me HOURS of refactoring time

How Did I Not Know This TypeScript Trick Earlier??!

Typescript tips | Part 1

TypeScript is Literal Magic



Views -