Code samples of advanced Typescript features
- numeric separator
To run each example in the folders, open a terminal and cd into the specific folder and enter "npm start".
Make sure you have installed @types/node using the following command in project root: npm install @types/node --save-dev
- ts-node for both compiling and running the typescript files, without having to deal with the compiled js files.
Type annotations : code we add to tell Typescript what type of value a variable will refer to, that is, we developers tell typescript the type of a variable or object etc. Ex: const apples: number = 5; In above code statement, ": number" is called the type annotation. Type annotations works with all object types (functions, arrays, classes, objects) and primitive types, string, number, symbol, null etc
Type inference : Typescript tries to figure out what type of value a variable refers to, that is, typescript tries to guess the type of an object, variable etc.