Skip to content

Commit 797d8bd

Browse files
authored
Call toPath on sourceRoot to ensure it is always absolute (microsoft#25838)
* Call toPath on sourceRoot to ensure it is always absolute * Leave canonicalization to avoid a Path/string union
1 parent 59854bb commit 797d8bd

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/compiler/sourcemapDecoder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace ts.sourcemaps {
6161

6262
export function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache = createSourceFileLikeCache(host)): SourceMapper {
6363
const currentDirectory = getDirectoryPath(mapPath);
64-
const sourceRoot = map.sourceRoot || currentDirectory;
64+
const sourceRoot = map.sourceRoot ? getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory;
6565
let decodedMappings: ProcessedSourceMapPosition[];
6666
let generatedOrderedMappings: ProcessedSourceMapPosition[];
6767
let sourceOrderedMappings: ProcessedSourceMapPosition[];
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/// <reference path="../fourslash.ts" />
2+
// @Filename: index.ts
3+
////export class Foo {
4+
//// member: string;
5+
//// /*2*/methodName(propName: SomeType): void {}
6+
//// otherMethod() {
7+
//// if (Math.random() > 0.5) {
8+
//// return {x: 42};
9+
//// }
10+
//// return {y: "yes"};
11+
//// }
12+
////}
13+
////
14+
////export interface SomeType {
15+
//// member: number;
16+
////}
17+
// @Filename: out/indexdef.d.ts.map
18+
////{"version":3,"file":"indexdef.d.ts","sourceRoot":"../","sources":["index.ts"],"names":[],"mappings":"AAAA;IACI,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}
19+
// @Filename: out/indexdef.d.ts
20+
////export declare class Foo {
21+
//// member: string;
22+
//// methodName(propName: SomeType): void;
23+
//// otherMethod(): {
24+
//// x: number;
25+
//// y?: undefined;
26+
//// } | {
27+
//// y: string;
28+
//// x?: undefined;
29+
//// };
30+
////}
31+
////export interface SomeType {
32+
//// member: number;
33+
////}
34+
//////# sourceMappingURL=out/indexdef.d.ts.map
35+
// @Filename: mymodule.ts
36+
////import * as mod from "./out/indexdef";
37+
////const instance = new mod.Foo();
38+
////instance.[|/*1*/methodName|]({member: 12});
39+
40+
verify.goToDefinition("1", "2");

0 commit comments

Comments
 (0)