Skip to content

paths work incorrect #667

@keyiis

Description

@keyiis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions