示例工程 11-template-literal-types

11-template-literal-types/04-type-arithmetic/README.md

markdown · 0.4 KB

运行:11 · type-arithmetic

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

# 04 · type-arithmetic
 
**演示**:用元组 `length` 做类型级加减法;只适合小整数,大数会显著拖慢检查。
**运行**:无运行时输出;Console 为空。
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/11-template-literal-types/04-type-arithmetic/tsconfig.types.json`
**注意**:这不是「类型系统支持算术」,而是用元组长度模拟;`Add<50, 50>` 会让 `tsc` 明显变慢。