gpt4 book ai didi

typescript - tsconfig.json 中的 gulp-typescript 和 outFile 选项

转载 作者:搜寻专家 更新时间:2023-10-30 20:54:02 25 4
gpt4 key购买 nike

我正在使用 gulpfile.js 以这种方式编译我的 tsconfig.json 项目:

var ts = require('gulp-typescript');

var tsProject = ts.createProject('Modeler/tsconfig.json',
{ typescript: require('typescript') });

gulp.task('build:ts', function () {
var tsResult = tsProject.src()
.pipe(ts(tsProject));
return tsResult.pipe(gulp.dest('wwwroot/app'));
});

它工作正常并编译我的 typescript 文件并将 js 文件放入 wwwroot/app 文件夹

问题出现了,然后我希望 TypeScript 编译器使用 outFile 属性输出单个串联文件

{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "commonjs",
"outFile": "modeler.js"
},
"exclude": [
"node_modules",
"wwwroot"
]
}

gulp 任务确实创建了一个空的输出文件,并创建了 *.js 文件,其内容紧挨着 *.ts 文件。

我应该如何修复才能创建所需的输出文件而不污染我的源文件夹?

最佳答案

您确定您的 TypeScript 源代码中没有外部模块吗?

我在那种情况下遇到过类似的行为。使用 outFile 选项时不允许外部模块,但编译器不会提示并发出空文件。此外,外部模块应该在“某处”发出(在 outDir 中)。

如果问题不在于使用普通 tsc -p 的外部模块。 的行为方式与使用 gulp-typescript 的方式相同?

关于typescript - tsconfig.json 中的 gulp-typescript 和 outFile 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33195766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com