To fix Promise is not recolized in TypeScript, we can choose to use a lib: npm i @types/es6-promise we can also use built-in libs: { "compilerOptions": { "module": "commonjs", "target": "es5", "noImpl…
/****************************************************************************************** Copyright 2013 Andrea Ragusa Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the Lice…
Best practices This is a guide to the best practices to follow when creating typing files. There are a variety of different ways that typing files can be constructed. Different approaches can be used - this is intended as a guide to what approaches m…
For example you are building your own module, the same as Lodash: my-lodash.d.ts declare module "lodash" { declare interface FirstFunction { (data: any[]) :any; } declare interface Lodash { first: FirstFunction; } export const _: Lodash: } Norma…
To avoid using "any" type is a best pratice. The reason for that is it disable the power of typescirpt to helping check you during the compile time. For example: currency(num: number){ cosnole.log(num.toFixed()); } In our currency function, it s…
TypeScript 2.0 introduced a new primitive type called never, the type of values that never occur. It helps model the completion behavior of functions more accurately and can also be used for exhaustiveness checking. never type means that 'That part o…
ypeScript 2.2 introduced the object, a type that represents any non-primitive type. It can be used to more accurately type methods such as Object.create. Don't confuse it with the Object type or {}, the empty object type, though! So one thing we need…
One aspect of control flow based type analysis is that the TypeScript compiler narrows the type of a variable within a type guard. This lesson explores how you can define functions and type predicates to create your own type guards similar to the Arr…
This lesson shows you how to install TypeScript and run the TypeScript compiler against a .ts file from the command line. install: npm install -g typescript tsc -v // version app.ts: class Person{} RUN: tsc app.ts You will see the js file with the sa…