引用
- MDN JS 原始值:链接
- ts null、undefined、strictNullChecks
原始类型
“原始类型”也被称为“平面类型”。
“非原始类型”被称为“立体类型”。
除了最常见的 number / string / boolean / null / undefined, ECMAScript 2015(ES6)、2020 (ES11) 又分别引入了 2 个新的原始类型:symbol 与 bigint 。

在 ts 中,所有 js 原始值都有对应的类型注解。除了 null 与 undefined 以外,余下的类型基本上可以完全对应到 js 中的数据类型概念。
const name: string = 'abc';const age: number = 123;const male: boolean = false;const undef: undefined = undefined;const nul: null = null;const obj: object = { name, age, male };const bigintVar1: bigint = 9007199254740991n;const bigintVar2: bigint = BigInt(9007199254740991);const symbolVar: symbol = Symbol('unique');
