首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用tsc时从d.ts生成p5.play.js文件的问题

使用tsc时从d.ts生成p5.play.js文件的问题
EN

Stack Overflow用户
提问于 2021-02-26 06:18:43
回答 1查看 185关注 0票数 2

我想为d.ts文件生成一个p5.play.js文件,因为没有这样的文件,而且由于p5.play.js是一个很大的库,所以输入它会很痛苦,而且我对d.ts文件非常陌生,这说明我只知道如何声明函数,p5.play.js也具有属性。但是,当我使用尝试创建它时,它会创建一个空的d.ts文件和export {};

以下是我尝试过的一些事情:

  1. I尝试使用tsconfig.json与tsc一起生成文件,但结果是export {};,下面是用于tsc的配置:

代码语言:javascript
复制
{
  // 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文件夹。

  1. 我尝试使用d.ts make和main.js,然后再次使用:export {};创建了一个d.ts文件,这里是my main.js for dts make:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-14 13:14:16

我也遇到了与您相同的问题,所以我没有找到预定义的p5.play.d.ts,而是为p5.play创建了自己的文件。该文件位于我的GitHub存储库中,希望它能帮助您!

链接到文件-> https://github.com/VisualCode44/Definition-File

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66381005

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档