no message

This commit is contained in:
WRSNDM\Administrator 2026-01-04 23:26:58 +08:00
parent a22eeeb940
commit 1ec3a43ab6

View File

@ -13,6 +13,22 @@
## 1. 基础概念与类型系统 ## 1. 基础概念与类型系统
在深入面试题之前,我们先快速梳理一下 TypeScript 的类型系统版图:
- 基础类型 (Primitives)`string`, `number`, `boolean`, `null`, `undefined`, `symbol`, `bigint`
- 顶层类型 (Top Types)
- `any`:关闭类型检查,尽量避免
- `unknown`:类型安全的 any使用前需类型收窄
- 底层类型 (Bottom Type)
- `never`:不可能出现的值(如抛错/死循环的返回)
- 复合类型 (Composed Types)
- 联合类型 (Union Types)`string | number`(是 A 或 B
- 交叉类型 (Intersection Types)`TypeA & TypeB`(同时满足 A 与 B
- 元组 (Tuple):定长定类型数组,如 `[string, number]`
- 对象类型:`interface``type`(对象字面量、映射类型)、`class`、字面量类型 `{ name: string }`
---
### Q1: `interface``type` (Type Alias) 的核心区别是什么?在什么场景下应该优先使用哪一个? ### Q1: `interface``type` (Type Alias) 的核心区别是什么?在什么场景下应该优先使用哪一个?
**解析:** **解析:**