Thursday, July 1, 2021

Type Inference in TypeScript | Example | Demo

Type Inference in TypeScript
TypeScript is a typed language. However, it is not mandatory to specify the type of a variable. TypeScript infers types of variables when there is no explicit information available in the form of type annotations.
Types are inferred by TypeScript compiler when:
1. Variables are initialized
2. Default values are set for parameters
3. Function return types are determined

Example



Demo


Demo Inference

No comments:

Post a Comment

How to build an Express and Node.js app with Typescript

  In this tutorial, you will learn how to set up a Node.js and Express project with Typescript and live auto-reloading. Note that this metho...