You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
If I use rootDirs (plural) and not rootDir (singular) in tsconfig.json, only rootDirs should be passed to the compiler.
Actual behavior:
compiler.ts synthesizes a value for rootDir, which is then passed to the compiler. This overrides rootDirs and causes my project to fail with gulp-typescript, even though it builds with tsc.
Your gulpfile:
Include your gulpfile, or only the related task (with ts.createProject).
importgulpfrom'gulp';importtsfrom'gulp-typescript';constmainProject=ts.createProject('tsconfig.json');functionbuildTypeScriptProject(project){constprojectSources=project.src();constprojectBuilder=project();constoutDir=project.options.outDir;constbuildResults=projectSources.pipe(projectBuilder);returnbuildResults.js.pipe(gulp.dest(outDir));}// Omitting the rather complicated generate-sources task...gulp.task('build',gulp.series('generate-sources',()=>{returnbuildTypeScriptProject(mainProject);}));
tsconfig.json
Include your tsconfig, if related to this issue.
{
// Use these TypeScript settings as defaults:"extends": "./tsconfig-base.json",
"compilerOptions": {
// output JS to dist/"outDir": "dist",
// Some generated modules should be found in generated/ as well.// Treat src/ and generated/ as equivalent during module resolution."rootDirs": ["src/", "generated/"],
},
"include": [
"src/**/*.ts",
],
}
Code
Include your TypeScript code, if necessary.
Not strictly necessary, given:
I have a simple fix in mind that works for me locally. In compiler.ts, rootDir is created on this.project.options, when it should instead be created on this. It should fall back through options.rootDir, options.rootDirs[0], and then finally the computed version that exists today. With this change made locally, everything works correctly. Either rootDir or rootDirs[0] can be used to determine the locations of things, but the config from tsconfig.json won't be modified inappropriately before being passed to the compiler.
I will send a PR shortly.
The text was updated successfully, but these errors were encountered:
It looks like you haven't updated typescript/dev in 3 years, but a regression test for this will not be effective without testing against TypeScript v4.
Expected behavior:
If I use
rootDirs
(plural) and notrootDir
(singular) in tsconfig.json, onlyrootDirs
should be passed to the compiler.Actual behavior:
compiler.ts synthesizes a value for
rootDir
, which is then passed to the compiler. This overridesrootDirs
and causes my project to fail withgulp-typescript
, even though it builds withtsc
.Your gulpfile:
Include your gulpfile, or only the related task (with
ts.createProject
).tsconfig.json
Include your tsconfig, if related to this issue.
Code
Include your TypeScript code, if necessary.
Not strictly necessary, given:
I have a simple fix in mind that works for me locally. In compiler.ts, rootDir is created on this.project.options, when it should instead be created on this. It should fall back through options.rootDir, options.rootDirs[0], and then finally the computed version that exists today. With this change made locally, everything works correctly. Either rootDir or rootDirs[0] can be used to determine the locations of things, but the config from tsconfig.json won't be modified inappropriately before being passed to the compiler.
I will send a PR shortly.
The text was updated successfully, but these errors were encountered: