-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Exposing canonical filename logic #37772
Comments
Instead of exposing |
Yeah, that probably makes more sense. I assume I'd be able to use |
I just noticed that TypeScript/lib/typescript.d.ts Lines 2926 to 2934 in f31b5a2
A workaround for my specific usecase could thus be: const host = ts.createCompilerHost(compilerOptions); //ugly, but necessary when using the transformer API (#37754)
const cache = ts.createModuleResolutionCache(currentDirectory, host.getCanonicalFileName, compilerOptions); |
Search Terms
canonical filename
Suggestion
I'd like to re-use the get-canonical-filename logic:
TypeScript/src/compiler/core.ts
Lines 1906 to 1909 in d68295e
Use Cases
I want to use
ts.resolveModuleName
and the accompanyingts.createModuleResolutionCache
to resolveImportDeclaration
s (as per this comment's suggestion).createModuleResolutionCache
requires a parametergetCanonicalFileName
. I think it makes the most sense to use the same logic as the compiler itself here, which is the function I linked above.I could just copy-and-paste this function, but that feels wrong and might lead to discrepancies in the future if
toFileNameLowerCase
(which is not exposed either) is ever updated.Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: