Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 502e711

Browse filesBrowse files
authored
Dont use sourcemap if it contains inlined sources (microsoft#36384)
Fixes microsoft#35014
1 parent 566202f commit 502e711
Copy full SHA for 502e711

File tree

Expand file treeCollapse file tree

2 files changed

+61
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+61
-0
lines changed

‎src/services/sourcemaps.ts

Copy file name to clipboardExpand all lines: src/services/sourcemaps.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ namespace ts {
181181
return undefined;
182182
}
183183

184+
// Dont support sourcemaps that contain inlined sources
185+
if (map.sourcesContent && map.sourcesContent.some(isString)) return undefined;
186+
184187
return createDocumentPositionMapper(host, map, mapFileName);
185188
}
186189

‎src/testRunner/unittests/tsserver/declarationFileMaps.ts

Copy file name to clipboardExpand all lines: src/testRunner/unittests/tsserver/declarationFileMaps.ts
+58Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,5 +654,63 @@ namespace ts.projectSystem {
654654
});
655655
assert.deepEqual<readonly protocol.FileCodeEdits[]>(response, []); // Should not change anything
656656
});
657+
658+
it("does not jump to source if inlined sources", () => {
659+
const aDtsInlinedSources: RawSourceMap = {
660+
...aDtsMapContent,
661+
sourcesContent: [aTs.content]
662+
};
663+
const aDtsMapInlinedSources: File = {
664+
path: aDtsMap.path,
665+
content: JSON.stringify(aDtsInlinedSources)
666+
};
667+
const host = createServerHost([aTs, aDtsMapInlinedSources, aDts, bTs, bDtsMap, bDts, userTs, dummyFile]);
668+
const session = createSession(host);
669+
670+
openFilesForSession([userTs], session);
671+
const service = session.getProjectService();
672+
// If config file then userConfig project and bConfig project since it is referenced
673+
checkNumberOfProjects(service, { inferredProjects: 1 });
674+
675+
// Inlined so does not jump to aTs
676+
assert.deepEqual(
677+
executeSessionRequest<protocol.DefinitionAndBoundSpanRequest, protocol.DefinitionAndBoundSpanResponse>(
678+
session,
679+
protocol.CommandTypes.DefinitionAndBoundSpan,
680+
protocolFileLocationFromSubstring(userTs, "fnA()")
681+
),
682+
{
683+
textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA"),
684+
definitions: [
685+
protocolFileSpanWithContextFromSubstring({
686+
file: aDts,
687+
text: "fnA",
688+
contextText: "export declare function fnA(): void;"
689+
})
690+
],
691+
}
692+
);
693+
694+
// Not inlined, jumps to bTs
695+
assert.deepEqual(
696+
executeSessionRequest<protocol.DefinitionAndBoundSpanRequest, protocol.DefinitionAndBoundSpanResponse>(
697+
session,
698+
protocol.CommandTypes.DefinitionAndBoundSpan,
699+
protocolFileLocationFromSubstring(userTs, "fnB()")
700+
),
701+
{
702+
textSpan: protocolTextSpanFromSubstring(userTs.content, "fnB"),
703+
definitions: [
704+
protocolFileSpanWithContextFromSubstring({
705+
file: bTs,
706+
text: "fnB",
707+
contextText: "export function fnB() {}"
708+
})
709+
],
710+
}
711+
);
712+
713+
verifySingleInferredProject(session);
714+
});
657715
});
658716
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.