Please enable JavaScript.
Coggle requires JavaScript to display documents.
TypeScript (type annotation (Special Types (null (--strictNullChecks),…
TypeScript
tsconfig.json
Project
Compilation Context
compiler options
which files
Declaration Spaces
Type Declaration Space
Variable Declaration Space
Modules
global.d.ts
file for common types, interfaces,
global namespace
lib.d.ts
?
--noLib
ambient declarations
common JS stuff
JS envs
browser
node.js
automatically included in the compilation context
Compiler target effect
--lib
type annotation
:TypeAnnotation
Primitive Types
string
number
boolean
Arrays
[] to any valid type annotation
Interfaces
compose multiple type annotations into a single
zero runtime JS impact
implements
Inline Type Annotation
:{ /
Structure
/ }
var myPoint: { x: number; y: number; };
Special Types
any
null
--strictNullChecks
undefined
--strictNullChecks
void
Generics
Union Type
string | number
Intersection Type
T & U
Tuple Type
: [string, number]
Type Alias
type StrOrNum = string|number;
Enums
organize a collection of related values
.d.ts extension
is a declaration file
JavaScript is valid TypeScript
DefinitelyTyped
types
Global
types
Module
types
Ambient Declarations
functions
overloading
no runtime
just documention
not arrow function
Callable
Newable
?
Type Assertion
inferred type
as foo vs. <foo>
is not casting
no any runtime
a compile time construct
Double assertion
?
the assertion from type S to T succeeds
either S is a subtype of T
or T is a subtype of S
Freshness
strict object literal checking
Type Guard
narrow down the type within a conditional block
typeof
instanceof
in