-
-
Notifications
You must be signed in to change notification settings - Fork 433
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 type reference directive resolution #936
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 |
---|---|---|
|
@@ -69,7 +69,9 @@ export function makeServicesHost( | |
fileExists, | ||
readFile: readFileWithFallback, | ||
realpath: compiler.sys.realpath, | ||
directoryExists: compiler.sys.directoryExists | ||
directoryExists: compiler.sys.directoryExists, | ||
getCurrentDirectory: compiler.sys.getCurrentDirectory, | ||
getDirectories: compiler.sys.getDirectories | ||
}; | ||
|
||
const clearCache = enableFileCaching ? addCache(moduleResolutionHost) : null; | ||
|
@@ -187,8 +189,11 @@ function makeResolvers( | |
): (typescript.ResolvedTypeReferenceDirective | undefined)[] => | ||
typeDirectiveNames.map( | ||
directive => | ||
resolveTypeReferenceDirective(directive, containingFile) | ||
.resolvedTypeReferenceDirective | ||
resolveTypeReferenceDirective( | ||
directive, | ||
containingFile, | ||
_redirectedReference | ||
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. This wasn't related to the particular repro provided, but it seemed like a place that might be broken for even edgier edge cases |
||
).resolvedTypeReferenceDirective | ||
); | ||
|
||
const resolveModuleName = makeResolveModuleName( | ||
|
@@ -500,7 +505,8 @@ export function makeWatchHost( | |
|
||
type ResolveTypeReferenceDirective = ( | ||
directive: string, | ||
containingFile: string | ||
containingFile: string, | ||
redirectedReference?: typescript.ResolvedProjectReference | ||
) => typescript.ResolvedTypeReferenceDirectiveWithFailedLookupLocations; | ||
|
||
function makeResolveTypeReferenceDirective( | ||
|
@@ -512,16 +518,17 @@ function makeResolveTypeReferenceDirective( | |
| undefined | ||
): ResolveTypeReferenceDirective { | ||
if (customResolveTypeReferenceDirective === undefined) { | ||
return (directive: string, containingFile: string) => | ||
return (directive, containingFile, redirectedReference) => | ||
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. Contextual parameter types FTW 😄 |
||
compiler.resolveTypeReferenceDirective( | ||
directive, | ||
containingFile, | ||
compilerOptions, | ||
moduleResolutionHost | ||
moduleResolutionHost, | ||
redirectedReference | ||
); | ||
} | ||
|
||
return (directive: string, containingFile: string) => | ||
return (directive, containingFile) => | ||
customResolveTypeReferenceDirective( | ||
directive, | ||
containingFile, | ||
|
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 if I understand this correctly, the fix is the implementation of these:
?
That's interesting. I wish it was more "fail fast" here if it actually needed these...
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.
Yep, specifically
getCurrentDirectory
. I agree. I'll suggest something like this to the team.