xgqfrms / typescript-in-action

TypeScript in Action
MIT License
1 stars 0 forks source link

TypeScript Types All In One #15

Open xgqfrms opened 3 years ago

xgqfrms commented 3 years ago

TypeScript Types All In One

https://www.typescriptlang.org/play#example/unknown-and-never

https://www.typescriptlang.org/play/?e=83#example/types-vs-interfaces

any, void, unknown, never,

interface, decorator, <T>范型, class, Tuple 元组

/*

There are already a small set of primitive types available in JavaScript:
boolean, bigint, null, number, string, symbol, and undefined,
which you can use in an interface.

TypeScript extends this list with a few more, such as
any (allow anything),
unknown (ensure someone using this type declares what the type is),
never (it’s not possible that this type could happen), and
void (a function which returns undefined or has no return value).

*/

// JS: boolean, bigint, null, number, string, symbol, and undefined,

// TS: any, unknown, never, void

https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html

https://www.typescriptlang.org/docs/handbook/typescript-tooling-in-5-minutes.html

https://www.typescriptlang.org/docs/handbook/utility-types.html

https://www.typescriptlang.org/docs/handbook/advanced-types.html

https://www.typescriptlang.org/docs/handbook/literal-types.html

xgqfrms commented 3 years ago

JS/ES Types

primitives: number, string, boolean, undefined, null, symbol, bigint

https://developer.mozilla.org/en-US/docs/Glossary/Primitive

image

complex: object (Object, Array, Map, Set, Function, Class, Proxy, Reflect, Date, Regex, ...)

https://developer.mozilla.org/en-US/docs/Glossary/Object

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures

image

https://developer.mozilla.org/en-US/docs/Glossary/Method