如何配置模具,使生成的ts文件不带双引号



现在,每当我运行命令stencil build --docs时,它都会生成内容低于的components.d.ts

/* eslint-disable */
/* tslint:disable */
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
export namespace Components {
interface MyButton {
/**
* Button text
*/
"text": string;
}
interface MyTab {
/**
* Tab active
*/
"active": boolean;

如果您注意到,所有属性实际上都带有双引号,我想知道如何删除引号,因为我们知道对于ts文件,这些引号不一定是必需的。

下面是我的tsconfig.json

{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"declaration": false,
"experimentalDecorators": true,
"lib": [
"dom",
"es2017"
],
"moduleResolution": "node",
"module": "esnext",
"target": "es2017",
"noUnusedLocals": true,
"noUnusedParameters": true,
"jsx": "react",
"jsxFactory": "h"
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}

原因是道具名称可以包含破折号,因此在生成文件时,为了简单起见,所有道具名称都会被引用。

Stencil没有为此提供配置,但也完全没有必要更改,因为1(文件是自动生成的(因此没有必要对其进行不同的格式化(,2(它是一个声明文件,不包含任何运行时代码(即文件大小无关紧要(。像VS Code这样的TypeScript编辑器提供了很好的智能感知,所以你可能永远不需要与这个文件交互,它只会给你很好的自动完成和内联文档。

您通常可以非常安全地git忽略该文件(第一次构建时会增加一些构建时间,因为它需要重新生成(,尽管官方建议将其添加到源代码管理中。

最新更新