Document order-dependence of isLocal flag (#49959)

This commit is contained in:
Andrew Casey 2022-07-19 14:38:35 -07:00 committed by GitHub
parent 5a53e9bb5e
commit 8402d657ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -344,6 +344,8 @@ namespace ts.server {
function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition, isForRename: boolean): DocumentPosition | undefined {
const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
const info = infos && firstOrUndefined(infos);
// Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file
// (implying that FAR cascading behavior may depend on request order)
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
}

View File

@ -1045,7 +1045,12 @@ namespace ts {
containerKind: ScriptElementKind;
containerName: string;
unverified?: boolean;
/* @internal */ isLocal?: boolean;
/** @internal
* Initially, this value is determined syntactically, but it is updated by the checker to cover
* cases like declarations that are exported in subsequent statements. As a result, the value
* may be "incomplete" if this span has yet to be checked.
*/
isLocal?: boolean;
/* @internal */ isAmbient?: boolean;
/* @internal */ failedAliasResolution?: boolean;
}