From 8402d657ab847aeabc0b58fdc723c8e07b0577f4 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 19 Jul 2022 14:38:35 -0700 Subject: [PATCH] Document order-dependence of isLocal flag (#49959) --- src/server/session.ts | 2 ++ src/services/types.ts | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/session.ts b/src/server/session.ts index 0fe57694d1a..d0aaf189214 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -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; } diff --git a/src/services/types.ts b/src/services/types.ts index 27c7616bf34..b9015a736d4 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -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; }