Closed puggan closed 4 years ago
May have solved it using gulp-flatmap:
.pipe(flatmap((stream, file) => stream.pipe(ts({"target": "ES5"}))))
flatmap works ok with 2 files, but fails with 3. according to a SO-answer, https://stackoverflow.com/questions/34693578/gulp-task-not-completing, "The problem you are facing is actually with the typescript compiler not able to run two instances in parallel,"
The combination gulp-cache, gulp-flatmap and gulp-typescript didn't work together. But after removeing the gulp-cache, things started to work again.
Set up a test project, to try to see what combinations works, and dosn't.
gulp-typescript will always compile all files in one namespace. gulp-flatmap sounds indeed like a good solution. It is possible to use multiple instances of gulp-typescript at once, if they do not share a tsproject.
As I end up here when googeling, I'l add the code I used recently:
// ES 5
.pipe(plug.flatmap((stream, file) => stream.pipe(plug.typescript.createProject({"target": "ES5", "lib": ["DOM", "ES5", "ScriptHost", "ES2015.Promise", "ES2015.Iterable"]})())))
// ES 6
.pipe(plug.flatmap((stream, file) => stream.pipe(plug.typescript.createProject({"target": "ES6", "lib": ["DOM", "ES6", "ScriptHost", "DOM.Iterable"]})())))
I have a few ts-scripts, that are executed on separate pages, but may have some common global variable name.
When using
gulp.src(['path/*.ts', '!path/*.d.ts']).pipe(ts({"target": "ES5"}))..
, it trows the error: "error TS2717: Subsequent property declarations must have the same type."How do I compile them separated/isolated from each other
Expected behavior: Each file compiled isolated, like
tsc a.ts; tsc b.ts; tsc c.ts
Actual behavior:
tsc a.ts b.ts c.ts
Your gulpfile: 200 lines: https://pastebin.com/1GGEpjfJ
tsconfig.json no
Code any code that generates TS2717 if compiled together, like: n.ts:
const a: number = 1;
s.ts:const a: string = "a";