示例工程 02-basic-types-inference
02-basic-types-inference/05-satisfies/README.md
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
# 05 · satisfies
**演示**:`satisfies` 检查对象是否符合约束,同时保留每个键的具体字面量类型;运行时零开销。
**运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开
`http://localhost:8080/examples/02-basic-types-inference/05-satisfies/`;开 Console。
**预期控制台输出**:
```text
home=/ GET
save=/save POST
annotated=/
```
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/02-basic-types-inference/05-satisfies/tsconfig.types.json`
**注意**:`typeof routes.home.method` 是 `"GET"`;若改成 `const routes: Record<string, Route>`,则变成 `"GET" | "POST"`。