我正在尝试使用Typescript和JSDocs做两件事:
第1步工作正常。
我在第2步中遇到了问题,特别是关于已声明模块的名称。
TS配置:
{
"compilerOptions": {
"module": "es6",
"moduleResolution": "node",
"target": "es6",
"checkJs": true,
"allowJs": true,
"outFile": "types/index.js",
"noImplicitAny": true,
"declaration": true,
"emitDeclarationOnly": true
},
"include": [
"./src/index.js"
]
}
我正在/ types中创建一个d.ts文件,主要问题是在该文件中,所有内容都在无法访问的模块中声明:
declare module "index" {...}
理想情况下,index
应该替换为软件包名称,以便import foo from 'package-name'
这里有完整的propro来演示这个问题: https://github.com/IamTheHttp/repro-typescript-jsdocs