gulp-typescript
gulp-typescript copied to clipboard
Definitions are not created
Expected behavior:
Generate d.ts when { "declaration": true }
assigned.
Actual behavior:
Only js files generated, tsconfig.json
works fine with tsc
directly.
Your gulpfile:
Include your gulpfile, or only the related task (with ts.createProject
).
// tsc
const tsProject = ts.createProject('tsconfig.json')
function tsc() {
const tsResult = tsProject.src().pipe(tsProject())
return merge([
tsResult.js,
tsResult.dts
])
.pipe(gulp.dest(ESM_DIR))
}
tsconfig.json
Include your tsconfig, if related to this issue.
{
"compilerOptions": {
"rootDir": "src",
"outDir": "./.cache/",
"target": "es6",
"declaration": true,
"jsx": "react-jsx",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"removeComments": true,
"sourceMap": true
},
"exclude": ["node_modules", "dist", "es", "development"],
"include": ["typings.d.ts", "src"]
}
Code
Include your TypeScript code, if necessary.
Besides, I checked the tsProject()
object, and found "declaration" within the "config" part is always false, no matter what the tsconfig.json or the setting param is.
Environment: [email protected] [email protected] [email protected]
I dug the source a little and found the problem came from this line, but I don't see the reason why these options are related to the isolatedModules
which is also not mentioned in official docs.
isolatedModules: false
saved me so much time, thank you @Artoria-0x04 !