示例工程 23-esm-live-bindings
23-esm-live-bindings/02-top-level-this/README.md
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
# 02 · top-level-this
**演示**:ES 模块顶层的 `this` 是 `undefined`,而 classic 脚本顶层是全局对象。
**运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开
`http://localhost:8080/examples/23-esm-live-bindings/02-top-level-this/`;开 Console。
**预期控制台输出**:
```text
topThis:undefined
```
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/23-esm-live-bindings/02-top-level-this/tsconfig.types.json`
**注意**:类型层对顶层 `this` 的建模与运行时不同;不要用类型判断它的值。