mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix for crash for auto import completions with a rooted rootDirs entry (#47411)
* Add failing test case. * Guard against undefined relative path.
This commit is contained in:
parent
14f33d5c4b
commit
461fb65623
@ -854,8 +854,8 @@ namespace ts.moduleSpecifiers {
|
||||
|
||||
function getPathRelativeToRootDirs(path: string, rootDirs: readonly string[], getCanonicalFileName: GetCanonicalFileName): string | undefined {
|
||||
return firstDefined(rootDirs, rootDir => {
|
||||
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)!; // TODO: GH#18217
|
||||
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
||||
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
||||
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
/// <reference path="./fourslash.ts" />
|
||||
|
||||
// @Filename: /dir/foo.ts
|
||||
//// export function foo() {}
|
||||
|
||||
// @Filename: /dir/bar.ts
|
||||
//// /*$*/
|
||||
|
||||
// @Filename: /dir/tsconfig.json
|
||||
////{
|
||||
//// "compilerOptions": {
|
||||
//// "module": "amd",
|
||||
//// "moduleResolution": "classic",
|
||||
//// "rootDirs": ["D:/"]
|
||||
//// }
|
||||
////}
|
||||
|
||||
goTo.marker("$");
|
||||
verify.completions({
|
||||
preferences: {
|
||||
includeCompletionsForModuleExports: true,
|
||||
allowIncompleteCompletions: true,
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user