示例工程 31-tsconfig-build-pipeline

31-tsconfig-build-pipeline/03-isolated-verbatim/README.md

markdown · 1.0 KB

运行:31 · isolated-verbatim

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

# 03 · isolated-verbatim
 
**演示**:`verbatimModuleSyntax` 下类型重导出必须 `export type`;`erasableSyntaxOnly` 下 `enum` 被拒绝。
**运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开
`http://localhost:8080/examples/31-tsconfig-build-pipeline/03-isolated-verbatim/`;开 Console。
**预期控制台输出**:
```text
rect
```
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/31-tsconfig-build-pipeline/03-isolated-verbatim/tsconfig.types.json`
**预期类型错误**:
```text
demo/reexport.ts(3,10): error TS1484: 'Shape' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
demo/reexport.ts(5,10): error TS1205: Re-exporting a type when 'verbatimModuleSyntax' is enabled requires using 'export type'.
demo/enum.ts(3,13): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
```
**注意**:这两个选项是「单文件转译」的前提;关掉它们,打包器就无法独立处理每个文件。