Closed akosyakov closed 6 years ago
@weswigham let me know if I can do something to help track down the issue, would be nice to have it in 3.1 🙏
I ran into the same issue too after adding project references
.
Here is screenshot from my debugging session:
Please note the red line is offending. I also see some strange file names such as dist8-*
instead of dist8/
, which is my outDir.
Which version of TypeScript was that, @akosyakov? I'm getting something similar in a different line with 3.0.3 while trying to use references
:
TypeError: Cannot read property 'path' of undefined
at node_modules/typescript/lib/tsc.js:45496:46
at Map.forEach (<anonymous>)
at createResolver (node_modules/typescript/lib/tsc.js:45491:49)
at Object.createTypeChecker (node_modules/typescript/lib/tsc.js:23813:28)
at getDiagnosticsProducingTypeChecker (node_modules/typescript/lib/tsc.js:67561:93)
at Object.getGlobalDiagnostics (node_modules/typescript/lib/tsc.js:67906:53)
at Object.emitFilesAndReportErrors (node_modules/typescript/lib/tsc.js:70217:46)
at performCompilation (node_modules/typescript/lib/tsc.js:71962:29)
at Object.executeCommandLine (node_modules/typescript/lib/tsc.js:71800:17)
at Object.<anonymous> (node_modules/typescript/lib/tsc.js:72087:4)
It's failing in the fileToDirective.set(file.path, key)
line below:
function createResolver() {
var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
var fileToDirective;
if (resolvedTypeReferenceDirectives) {
fileToDirective = ts.createMap();
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
return;
}
var file = host.getSourceFile(resolvedDirective.resolvedFileName);
fileToDirective.set(file.path, key);
});
}
return {
…
}
};
In my case, host.getSourceFile
returned undefined
for node_modules/@types/code/index.d.ts
, as shipped in @types/code
4.0.4.
If I return
if !file
, I get
error TS6305: Output file '/Users/me/src/repo/dist/node_modules/@types/code/index.d.ts' has not been built from source file '/Users/me/src/repo/pkg/packagename/node_modules/@types/code/index.d.ts'.
I'm not sure why it's expecting an output file in ../../../dist
relative to the directory I'm running tsc
in, /Users/me/src/repo/pkg/packagename/test
.
I've tried with rc 3.1. It's still there.
This seems to be fixed with typescript@next and errors are reported. without any crash
Thank you! Just verified it does not fail anymore.
I am trying to migrate Theia monorepo to project references: https://github.com/theia-ide/theia/pull/2563/files
But it fails during the compilation: