如何配置 stencil 使生成的 ts 文件不带双引号
How to configure stencil so that generated ts file doesnt come with double quotes
现在每当我 运行 命令 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"
]
}
原因是 prop 名称可以包含破折号,因此在生成文件时为了简单起见,所有 prop 名称都被引用。
Stencil 没有为此提供任何配置,但也完全没有必要更改它,因为 1) 文件是 auto-generated(因此没有必要以不同的方式格式化它)和 2) 它是一个声明文件不包含任何运行时代码(即文件大小无关紧要)。像 VS Code 这样的 TypeScript 编辑器提供了很好的智能感知,所以你可能永远不必与这个文件交互,它只会给你很好的 auto-completion 和内联文档。
您通常可以非常安全地 git-ignore 文件(在第一次构建时会增加一些构建时间,因为它需要重新生成),即使官方建议将其添加到 source-control 中。
现在每当我 运行 命令 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"
]
}
原因是 prop 名称可以包含破折号,因此在生成文件时为了简单起见,所有 prop 名称都被引用。
Stencil 没有为此提供任何配置,但也完全没有必要更改它,因为 1) 文件是 auto-generated(因此没有必要以不同的方式格式化它)和 2) 它是一个声明文件不包含任何运行时代码(即文件大小无关紧要)。像 VS Code 这样的 TypeScript 编辑器提供了很好的智能感知,所以你可能永远不必与这个文件交互,它只会给你很好的 auto-completion 和内联文档。
您通常可以非常安全地 git-ignore 文件(在第一次构建时会增加一些构建时间,因为它需要重新生成),即使官方建议将其添加到 source-control 中。