Typescript. d.ts files
needed to use js code in ts code through declarations
looks like this stackoverflow post describes it the best
as i understood js files and
needed to use js code in ts code through declarations
looks like this stackoverflow post describes it the best
as i understood js files and
Modules also created to group out code. Lets look at example
hi.ts // this will be the module
export default function sayHi() { console.log(‘hi, there’);
namespaces allow logically group our code
namespace Animals { interface Animal { sayHi(): void } class Dog implements Animal { sayHi(): void { console.log(‘av-av’); }
function foo<T>(x: T): T { // calc return x; } console.log(foo<string>(‘hi, there’)); console.log(foo<number>(123)); // — extends for generics function foo2<T extends { name: string
as it was mentioned in DataTypes post there are 2 ways of assertions through as and <type> operators
// Type assertions const myCanvas =