示例工程 26-module-comparison-monorepo

26-module-comparison-monorepo/02-namespace-globals/README.md

markdown · 0.7 KB

运行:26 · namespace-globals

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

# 02 · namespace-globals
 
**演示**:`declare namespace App` + `declare global { interface Window }` 仍是全局类型分组的有效手段。
**运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开
`http://localhost:8080/examples/26-module-comparison-monorepo/02-namespace-globals/`;开 Console。
**预期控制台输出**:
```text
https://api.example.com:1.0.0
```
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/26-module-comparison-monorepo/02-namespace-globals/tsconfig.types.json`
**注意**:声明合并只在类型层;`window.App` 由页面脚本提供,缺失时 `run()` 返回空数组。