[英]How to generate .d.ts file only for javascript files?
Since my project is not started with Typescript, so there're some Javascript files yet.由于我的项目不是从 Typescript 开始的,所以还有一些 Javascript 文件。
So my idea is to generate a @types
directory with .d.ts
files for all the .jsx?
所以我的想法是为所有.jsx 生成一个带有
.d.ts
文件的@types
目录.jsx?
files (only .jsx?
files)文件(仅
.jsx?
文件)
My tsconfig.json
is like this:我的
tsconfig.json
是这样的:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6"],
"moduleResolution": "node",
"strict": true,
"emitDeclarationOnly": true,
"target": "esnext",
"baseUrl": "./src",
"paths": {
"~/*": ["*"]
},
"declaration": true,
"declarationDir": "./types"
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js",
"*.ts",
"*.tsx"
],
"include": [ "src/**/*.js", "src/**/*.jsx" ]
}
It's working partially, because it's also creating .d.ts
file to .tsx?
它正在部分工作,因为它还在将
.d.ts
文件创建为.tsx?
files.文件。
How can I generate .d.ts
files only for .jsx
and .js
files?如何仅为
.jsx
和.js
文件生成.d.ts
文件?
.dts is self documet file. .dts 是自文档文件。 compaler can't know type of fuinction or type of variable.
Compaler 不知道函数的类型或变量的类型。 If you use for js you must write widt your hands.
如果您使用 js,您必须亲手编写。 You can use js doc sysntax.
您可以使用 js 文档 sysntax。 https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler
https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.