Skip to content

Commit b521fd5

Browse files
committed
Allow --sourceRoot with --inlineSources option
Fixes #8445
1 parent 75b8293 commit b521fd5

9 files changed

+27
-28
lines changed

src/compiler/diagnosticMessages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@
22602260
"category": "Error",
22612261
"code": 5047
22622262
},
2263-
"Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
2263+
"Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
22642264
"category": "Error",
22652265
"code": 5051
22662266
},

src/compiler/program.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -2043,27 +2043,22 @@ namespace ts {
20432043
}
20442044
}
20452045

2046-
if (options.inlineSources) {
2047-
if (!options.sourceMap && !options.inlineSourceMap) {
2048-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
2046+
if (!options.sourceMap && !options.inlineSourceMap) {
2047+
if (options.inlineSources) {
2048+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources"));
20492049
}
20502050
if (options.sourceRoot) {
2051-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSources"));
2051+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot"));
20522052
}
20532053
}
20542054

20552055
if (options.out && options.outFile) {
20562056
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
20572057
}
20582058

2059-
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
2060-
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
2061-
if (options.mapRoot) {
2062-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
2063-
}
2064-
if (options.sourceRoot && !options.inlineSourceMap) {
2065-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
2066-
}
2059+
if (options.mapRoot && !options.sourceMap) {
2060+
// Error to specify --mapRoot without --sourcemap
2061+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
20672062
}
20682063

20692064
if (options.declarationDir) {

tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.errors.txt

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts ===
2+
3+
var a = 10;
4+
>a : Symbol(a, Decl(optionsSourcemapInlineSourcesSourceRoot.ts, 1, 3))
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts ===
2+
3+
var a = 10;
4+
>a : number
5+
>10 : number
6+

tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
12
error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
2-
error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
33

44

5+
!!! error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
56
!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
6-
!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
77
==== m1.ts (0 errors) ====
88
var m1_a1 = 10;
99
class m1_c1 {

tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
12
error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
2-
error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
33

44

5+
!!! error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
56
!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
6-
!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
77
==== m1.ts (0 errors) ====
88
var m1_a1 = 10;
99
class m1_c1 {

tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
1+
error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
22

33

4-
!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
4+
!!! error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
55
==== m1.ts (0 errors) ====
66
var m1_a1 = 10;
77
class m1_c1 {

tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
1+
error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
22

33

4-
!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'.
4+
!!! error TS5051: Option 'sourceRoot can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.
55
==== m1.ts (0 errors) ====
66
var m1_a1 = 10;
77
class m1_c1 {

0 commit comments

Comments
 (0)