Skip to content

Commit a4991b9

Browse files
authored
Merge pull request #9057 from Microsoft/sourceRootWithInlineSources
Allow --sourceRoot with --inlineSources option
2 parents 574a64d + b521fd5 commit a4991b9

9 files changed

+27
-28
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,27 +2105,22 @@ namespace ts {
21052105
}
21062106
}
21072107

2108-
if (options.inlineSources) {
2109-
if (!options.sourceMap && !options.inlineSourceMap) {
2110-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
2108+
if (!options.sourceMap && !options.inlineSourceMap) {
2109+
if (options.inlineSources) {
2110+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources"));
21112111
}
21122112
if (options.sourceRoot) {
2113-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSources"));
2113+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot"));
21142114
}
21152115
}
21162116

21172117
if (options.out && options.outFile) {
21182118
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
21192119
}
21202120

2121-
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
2122-
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
2123-
if (options.mapRoot) {
2124-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
2125-
}
2126-
if (options.sourceRoot && !options.inlineSourceMap) {
2127-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
2128-
}
2121+
if (options.mapRoot && !options.sourceMap) {
2122+
// Error to specify --mapRoot without --sourcemap
2123+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
21292124
}
21302125

21312126
if (options.declarationDir) {

tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.errors.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
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+
Lines changed: 6 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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)