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

问题描述

现在,每当我运行命令def buildMenu(names,values,calories): menu=[] for i in range(len(values)): menu.append(Food(names[i],values[i],calories[i])) return menu Total value of items taken 318.0 apple: <50,95> wine: <89,123> cola: <79,150> beer: <90,154> donut: <10,195> 时,它将生成内容如下的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

解决方法

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

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

即使官方建议将其添加到源代码管理中,您也通常可以非常安全地git-ignore文件(由于需要重新生成文件,因此首次构建时会增加一些构建时间)。