【问题标题】:Does stencil use tsconfig.json?模具是否使用 tsconfig.json?
【发布时间】:2020-03-13 04:14:30
【问题描述】:
我正在使用 Visual Studio Code 在模板的帮助下开发 Web 组件。编写基本组件需要在 typescript 文件中使用装饰器。 Visual Studio Code 向我显示了一条错误消息,因为 typescript 中默认不支持装饰器。在根目录中创建 tsconfig.json 并将此 "experimentalDecorators": true 添加到其中,抑制了警告。现在我想知道,模板编译器会使用这个配置来处理打字稿还是它只是一些 IDE 特定工具的配置?
【问题讨论】:
标签:
typescript
visual-studio-code
tsconfig
stenciljs
【解决方案1】:
是的,Stencil 使用项目中的 tsconfig.json 进行 TypeScript 转换步骤,但会覆盖 compilerOptions 的某些值。在撰写本文时,这些是:
compilerOptions.isolatedModules = false;
compilerOptions.suppressOutputPathCheck = true;
compilerOptions.allowNonTsExtensions = true;
compilerOptions.removeComments = false;
compilerOptions.sourceMap = false;
compilerOptions.lib = undefined;
compilerOptions.types = undefined;
compilerOptions.noEmit = undefined;
compilerOptions.noEmitOnError = undefined;
compilerOptions.rootDirs = undefined;
compilerOptions.declaration = undefined;
compilerOptions.declarationDir = undefined;
compilerOptions.out = undefined;
compilerOptions.outFile = undefined;
compilerOptions.outDir = undefined;
见src/compiler/transpile/transpile-service.ts#L72-L89。
experimentalDecorators 也是 Stencil 使用的一项功能,因此应在您的 tsconfig 中启用。您可以查看tsconfig of the stencil-app-starter 的推荐值。