-
Notifications
You must be signed in to change notification settings - Fork 790
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
fix(compiler): address when a home module cannot be found #4521
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -519,18 +519,20 @@ const getTypeReferenceLocation = ( | |
const compilerHost = ts.createCompilerHost(options); | ||
const importHomeModule = getHomeModule(sourceFile, localImportPath, options, compilerHost, program); | ||
|
||
const importName = namedImportBindings.elements.find((nbe) => nbe.name.getText() === typeName).name; | ||
const originalTypeName = getOriginalTypeName(importName, checker); | ||
|
||
const typeDecl = findTypeWithName(importHomeModule, originalTypeName); | ||
type = checker.getTypeAtLocation(typeDecl); | ||
|
||
const id = addToLibrary(type, originalTypeName, checker, normalizePath(importHomeModule.fileName, false)); | ||
return { | ||
location: 'import', | ||
path: localImportPath, | ||
id, | ||
}; | ||
if (importHomeModule) { | ||
const importName = namedImportBindings.elements.find((nbe) => nbe.name.getText() === typeName).name; | ||
const originalTypeName = getOriginalTypeName(importName, checker); | ||
|
||
const typeDecl = findTypeWithName(importHomeModule, originalTypeName); | ||
type = checker.getTypeAtLocation(typeDecl); | ||
|
||
const id = addToLibrary(type, originalTypeName, checker, normalizePath(importHomeModule.fileName, false)); | ||
return { | ||
location: 'import', | ||
path: localImportPath, | ||
id, | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this now return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, since there's still the code below which deals with the case that this is a global type and so on |
||
} | ||
|
||
// Loop through all top level exports to find if any reference to the type for 'local' reference location | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So TS thinks any type it can't resolve is just a global? Or is this something we're doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah basically, if a type isn't imported into the module or declared inside of it we can safely assume it's a global type