You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The basic structure is defined i.e. the permissible keys and their respective types.
array
let a : string[] a = [12]
above statement will throw an error let a: any[] a= [12,'aa']
above statement will not throw an error
An array can be flexible as well as strict
tuples
An array of fixed size and fixed type of each element.
let a: [string,number]; a = [1,'sad']; a = [2,'ad','sds'];
enum
enum a {AUTHOR = 1 , EDITOR = 2 , DIRECTOR = 3}
union type
let account : number | string
literal (variable name) type
const a = 12
the type of a is 12
The types based on core types, like '12' itself can be a type of a variable whose value can only be 12.
alias type
type combinedTypes = number | stringtype stringValues = 'as-text' | 'as-number'
function return type and void
function sum(n1 : number, n2: number):number
the returned values by function are of number type
function type
let f : Function
function a(n1: number, n2: number, cb: (a:number) => void)