![](/img/trans.png)
[英]Is it possible to generate TypeScript Type Definition/Declaration files?
[英]Why Snowpack is not taking my type declaration files?
我在雪包中有以下配置:
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
mount: {
public:{ url: '/', static: true },
src: { url: '/dist' },
runtime: { url: '/runtime' },
},
plugins: [
'@snowpack/plugin-typescript',
['@snowpack/plugin-babel',
{
'input': ['.ts', '.tsx'],
}
]
],
packageOptions: {
/* ... */
},
devOptions: {
/* ... */
},
buildOptions: {
/* ... */
},
};
这在我的声明文件index.d.ts
中,但是当我启动开发服务器时,Snowpack 没有读取它。
declare global {
namespace JSX {
interface IntrinsicElements {
[elName: string]: any;
}
}
}
让它工作的唯一方法是将文件名更改为index.ts
您提出问题的方式 - snowpack '不采取' your.d.ts 文件 - 对我来说有点含糊。 如果您的意思是您的编辑器(假设 VSCode)没有给您自动完成功能,请尝试将文件添加到 tsconfig.json 中的“包含”数组中:
{
"include": [
...
"index.d.ts",
]
}
我从 create-snowpack-app CLI 工具使用的基本 typescript 模板中找到了这个解决方案: https://github.com/snowpackjs/snowpack/tree/main/create-snowpack-app/app-template-blank-typescript .d.ts 文件位于“types”文件夹中,然后该文件夹包含在 tsconfig 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.