Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paths work incorrect #667

Open
keyiis opened this issue Dec 1, 2021 · 4 comments
Open

paths work incorrect #667

keyiis opened this issue Dec 1, 2021 · 4 comments

Comments

@keyiis
Copy link

keyiis commented Dec 1, 2021

Gulp-typescript encountered an error when I upgraded typescript from 3.9 to 4.5
env:
[email protected]
[email protected]
tsconfig:

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        // "allowSyntheticDefaultImports": true,
        // "noUnusedLocals": true,
        "removeComments": true,
        "skipLibCheck":true,
        "sourceMap": true,
        "declaration": false,
        "pretty": true,
        // "strictNullChecks": true,
        "lib": [
            "es2015",
            "es2016",
            "es2017"
        ],
        "baseUrl": ".",
        "paths": {
            "@common/*": [ "src/common/*" ]
        }
    }
}

directory structure:

D:/edge
    src
        common/*
        projects/core/*
    tsconfig.json

gulp script

let tsProject = ts.createProject("tsconfig.json");
gulp.src([`D:/edge/src/projects/core/**/*.ts`], { base: `D:/edge/src/projects/core` })
        .pipe(cached('compileProject'))    
        .pipe(tsProject())
        .pipe(gulp.dest(DIST_PATH));

error:

D:/edge/src/common/entitys/index.ts(1,15): error TS6059: File 'D:/edge/src/common/entitys/Job.ts' is not under 'rootDir' 'src\projects\core'. 'rootDir' is expected to contain all source files.
D:/edge/src/common/entitys/Job.ts(2,28): error TS6059: File 'D:/edge/src/common/config.ts' is not under 'rootDir' 'src\projects\core'. 'rootDir' is expected to contain all source files.
  The file is in the program because:
    Imported via '@common/config' from file 'D:/edge/src/common/entitys/Job.ts'
    Imported via './config' from file 'D:/edge/src/common/dbUtil.ts'

when i downgrade Gulp-typescript to 3.9,all work well,when I searched typescript's help manual, I found below
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#paths-without-baseurl
But I removed baseurl, and the error still exists.

@bmayen
Copy link

bmayen commented Dec 1, 2021

just ran into this as well. Works with typescript ~4.2.0 but breaks with ~4.3.0

@keyiis
Copy link
Author

keyiis commented Dec 2, 2021

@bmayen I just did the test, just like you.

@ivogabe
Copy link
Owner

ivogabe commented Dec 14, 2021

Contrary to tsc, we must always set rootDir in gulp-typescript to work with the virtual file system in gulp. It's inferred from the input stream (e.g. from gulp.src) but if it's inferred incorrectly you'll need to specify it yourself. Can you try to add that option?

@akaDPR
Copy link

akaDPR commented Dec 29, 2021

Contrary to tsc, we must always set rootDir in gulp-typescript to work with the virtual file system in gulp. It's inferred from the input stream (e.g. from gulp.src) but if it's inferred incorrectly you'll need to specify it yourself. Can you try to add that option?

I face the same issue @ivogabe I upgraded the typescript version from 4.1 to 4.5. as you suggested I specified the input stream but still not working. please help us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants