我想为d.ts文件生成一个p5.play.js文件,因为没有这样的文件,而且由于p5.play.js是一个很大的库,所以输入它会很痛苦,而且我对d.ts文件非常陌生,这说明我只知道如何声明函数,p5.play.js也具有属性。但是,当我使用尝试创建它时,它会创建一个空的d.ts文件和export {};。
以下是我尝试过的一些事情:
export {};,下面是用于tsc的配置:{
// Change this to match your project
"include": ["src/"],
"compilerOptions": {
// Tells TypeScript to read JS files, as
// normally they are ignored as source files
"allowJs": true,
// Generate d.ts files
"declaration": true,
// This compiler run should
// only output d.ts files
"emitDeclarationOnly": true,
// Types should go into this directory.
// Removing this would place the .d.ts files
// next to the .js files
"outDir": "dist"
}
}是我有p5.play.js文件的src文件夹。
export {};创建了一个d.ts文件,这里是my main.js for dts make:require('dts-generator').default({
name: 'p5.play',
project: 'src/',
out: 'p5.play.d.ts'
});再一次在src里,我有p5.play.js。
如果有帮助的话,这里是dts /make https://www.npmjs.com/package/dts-generator的npm,下面是p5.play.js库:https://github.com/molleindustria/p5.play/blob/master/lib/p5.play.js
发布于 2021-05-14 13:14:16
我也遇到了与您相同的问题,所以我没有找到预定义的p5.play.d.ts,而是为p5.play创建了自己的文件。该文件位于我的GitHub存储库中,希望它能帮助您!
https://stackoverflow.com/questions/66381005
复制相似问题