This bug is occurring in a monorepo project managed with Yarn Workspaces. I've recently upgraded it to TypeScript 3 and was looking to take advantage of Project References. To do this, I set composite: true under compilerOptions in tsconfig.json for each subpackage. If I set it to false, then everything works fine.
$ tslint -p tsconfig.json -t codeFrame 'src/**/*.ts' -e 'src/**/*.spec.ts'
TypeError: Cannot read property 'replace' of undefined
at Object.normalizeSlashes (/[PROJECT_PATH]]/node_modules/typescript/lib/typescript.js:14080:21)
at getCommonSourceDirectory (/[PROJECT_PATH]]/node_modules/typescript/lib/typescript.js:82737:68)
at verifyCompilerOptions (/[PROJECT_PATH]]/node_modules/typescript/lib/typescript.js:84278:27)
at Object.createProgram (/[PROJECT_PATH]]/node_modules/typescript/lib/typescript.js:82703:9)
at Function.Linter.createProgram (/[PROJECT_PATH]]/packages/framework/node_modules/tslint/lib/linter.js:80:26)
at resolveFilesAndProgram (/[PROJECT_PATH]]/packages/framework/node_modules/tslint/lib/runner.js:120:35)
at /[PROJECT_PATH]]/packages/framework/node_modules/tslint/lib/runner.js:90:18
at step (/[PROJECT_PATH]]/node_modules/tslib/tslib.js:133:27)
at Object.next (/[PROJECT_PATH]]/node_modules/tslib/tslib.js:114:57)
at /[PROJECT_PATH]]/node_modules/tslib/tslib.js:107:75
It should lint with no problems.
Duplicate of https://github.com/palantir/tslint/issues/4137
Oops, seems like this is infact not a duplicate - just two related issues to do with project references.
I'm guessing this just requires tslint to update tslib - maybe you can try it out and make a PR.
I upgraded tslib in a local copy of tslint, but it didn't seem to fix the issue ๐ข
The workaround might be obvious to some, perhaps, but I thought I'd share mine in case it helps someone.
tsconfig.lint.json: {
"extends": "./tsconfig.json",
"compilerOptions": {
// https://github.com/palantir/tslint/issues/4148
"composite": false
}
}
tslint --project tsconfig.lint.json instead of tslint --project .TSLint is deprecated and no longer accepting pull requests other than security fixes. See #4534. โ ๏ธ
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. โ
๐ It was a pleasure open sourcing with you!
๐ค Beep boop! ๐ TSLint is deprecated ๐ _(#4534)_ and you should switch to typescript-eslint! ๐ค
๐ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐
Most helpful comment
The workaround might be obvious to some, perhaps, but I thought I'd share mine in case it helps someone.
tsconfig.lint.json:tslint --project tsconfig.lint.jsoninstead oftslint --project .