Skip to content

Commit 1659300

Browse files
committed
Fix the --sourceRoot and --mapRoot option handling
1 parent 8020bf9 commit 1659300

11 files changed

+68
-25
lines changed

src/compiler/program.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -990,16 +990,15 @@ namespace ts {
990990
if (options.mapRoot) {
991991
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
992992
}
993-
if (options.sourceRoot) {
994-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
995-
}
996993
}
997994

998-
999995
if (options.inlineSources) {
1000996
if (!options.sourceMap && !options.inlineSourceMap) {
1001997
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
1002998
}
999+
if (options.sourceRoot) {
1000+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSources"));
1001+
}
10031002
}
10041003

10051004
if (options.out && options.outFile) {
@@ -1011,10 +1010,9 @@ namespace ts {
10111010
if (options.mapRoot) {
10121011
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
10131012
}
1014-
if (options.sourceRoot) {
1013+
if (options.sourceRoot && !options.inlineSourceMap) {
10151014
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
10161015
}
1017-
return;
10181016
}
10191017

10201018
const languageVersion = options.target || ScriptTarget.ES3;

tests/baselines/reference/inlineSourceMap2.errors.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
22
error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
3-
error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.
43
tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'.
54

65

76
!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
87
!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
9-
!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.
108
==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ====
119

1210
// configuration errors

tests/baselines/reference/optionsInlineSourceMapMapRoot.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/optionsInlineSourceMapMapRoot.sourcemap.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
===================================================================
22
JsFile: optionsInlineSourceMapMapRoot.js
3-
mapUrl: c:/TypeScript/tests/cases/compiler/optionsInlineSourceMapMapRoot.js.map
3+
mapUrl: local/optionsInlineSourceMapMapRoot.js.map
44
sourceRoot:
5-
sources: optionsInlineSourceMapMapRoot.ts
5+
sources: ../optionsInlineSourceMapMapRoot.ts
66
===================================================================
77
-------------------------------------------------------------------
88
emittedFile:tests/cases/compiler/optionsInlineSourceMapMapRoot.js
9-
sourceFile:optionsInlineSourceMapMapRoot.ts
9+
sourceFile:../optionsInlineSourceMapMapRoot.ts
1010
-------------------------------------------------------------------
1111
>>>var a = 10;
1212
1 >
@@ -15,7 +15,7 @@ sourceFile:optionsInlineSourceMapMapRoot.ts
1515
4 > ^^^
1616
5 > ^^
1717
6 > ^
18-
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
18+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1919
1 >
2020
>
2121
2 >var
@@ -30,4 +30,4 @@ sourceFile:optionsInlineSourceMapMapRoot.ts
3030
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
3131
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
3232
---
33-
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcE1hcFJvb3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJvcHRpb25zSW5saW5lU291cmNlTWFwTWFwUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==
33+
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcE1hcFJvb3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9vcHRpb25zSW5saW5lU291cmNlTWFwTWFwUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

tests/baselines/reference/optionsInlineSourceMapSourceRoot.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
===================================================================
2+
JsFile: optionsInlineSourceMapSourceRoot.js
3+
mapUrl: optionsInlineSourceMapSourceRoot.js.map
4+
sourceRoot: local/
5+
sources: optionsInlineSourceMapSourceRoot.ts
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:tests/cases/compiler/optionsInlineSourceMapSourceRoot.js
9+
sourceFile:optionsInlineSourceMapSourceRoot.ts
10+
-------------------------------------------------------------------
11+
>>>var a = 10;
12+
1 >
13+
2 >^^^^
14+
3 > ^
15+
4 > ^^^
16+
5 > ^^
17+
6 > ^
18+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
19+
1 >
20+
>
21+
2 >var
22+
3 > a
23+
4 > =
24+
5 > 10
25+
6 > ;
26+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
27+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
28+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
29+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
30+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
31+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
32+
---
33+
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZVJvb3QuanMiLCJzb3VyY2VSb290IjoibG9jYWwvIiwic291cmNlcyI6WyJvcHRpb25zSW5saW5lU291cmNlTWFwU291cmNlUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts ===
2+
3+
var a = 10;
4+
>a : Symbol(a, Decl(optionsInlineSourceMapSourceRoot.ts, 1, 3))
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts ===
2+
3+
var a = 10;
4+
>a : number
5+
>10 : number
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSources'.
2+
3+
4+
!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSources'.
5+
==== tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts (0 errors) ====
6+
7+
var a = 10;

tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.symbols

-5
This file was deleted.

tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.types

-6
This file was deleted.

0 commit comments

Comments
 (0)