Skip to content

Commit 8452ada

Browse files
committed
Fix SourceFileAffecting for options used in binder
1 parent 6cf997a commit 8452ada

File tree

3 files changed

+29
-47
lines changed

3 files changed

+29
-47
lines changed

internal/core/compileroptions.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,22 +264,30 @@ func (options *CompilerOptions) HasJsonModuleEmitEnabled() bool {
264264
// changed require a new SourceFile be created.
265265
type SourceFileAffectingCompilerOptions struct {
266266
// !!! generate this
267-
Target ScriptTarget
268-
Jsx JsxEmit
269-
JsxImportSource string
270-
ImportHelpers Tristate
271-
AlwaysStrict Tristate
272-
ModuleDetection ModuleDetectionKind
267+
Target ScriptTarget
268+
Jsx JsxEmit
269+
JsxImportSource string
270+
ImportHelpers Tristate
271+
AlwaysStrict Tristate
272+
ModuleDetection ModuleDetectionKind
273+
AllowUnreachableCode Tristate
274+
AllowUnusedLabels Tristate
275+
PreserveConstEnums Tristate
276+
IsolatedModules Tristate
273277
}
274278

275279
func (options *CompilerOptions) SourceFileAffecting() SourceFileAffectingCompilerOptions {
276280
return SourceFileAffectingCompilerOptions{
277-
Target: options.Target,
278-
Jsx: options.Jsx,
279-
JsxImportSource: options.JsxImportSource,
280-
ImportHelpers: options.ImportHelpers,
281-
AlwaysStrict: options.AlwaysStrict,
282-
ModuleDetection: options.ModuleDetection,
281+
Target: options.Target,
282+
Jsx: options.Jsx,
283+
JsxImportSource: options.JsxImportSource,
284+
ImportHelpers: options.ImportHelpers,
285+
AlwaysStrict: options.AlwaysStrict,
286+
ModuleDetection: options.ModuleDetection,
287+
AllowUnreachableCode: options.AllowUnreachableCode,
288+
AllowUnusedLabels: options.AllowUnusedLabels,
289+
PreserveConstEnums: options.PreserveConstEnums,
290+
IsolatedModules: options.IsolatedModules,
283291
}
284292
}
285293

testdata/baselines/reference/submodule/compiler/unreachableDeclarations(preserveconstenums=false).errors.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ unreachableDeclarations.ts(14,5): error TS7027: Unreachable code detected.
44
unreachableDeclarations.ts(21,17): error TS2450: Enum 'EnumA' used before its declaration.
55
unreachableDeclarations.ts(29,5): error TS7027: Unreachable code detected.
66
unreachableDeclarations.ts(29,5): error TS7027: Unreachable code detected.
7-
unreachableDeclarations.ts(43,5): error TS7027: Unreachable code detected.
8-
unreachableDeclarations.ts(43,5): error TS7027: Unreachable code detected.
97
unreachableDeclarations.ts(49,17): error TS2449: Class 'ClassA' used before its declaration.
108
unreachableDeclarations.ts(57,5): error TS7027: Unreachable code detected.
119
unreachableDeclarations.ts(57,5): error TS7027: Unreachable code detected.
@@ -18,7 +16,7 @@ unreachableDeclarations.ts(78,2): error TS7027: Unreachable code detected.
1816
unreachableDeclarations.ts(84,2): error TS1235: A namespace declaration is only allowed at the top level of a namespace or module.
1917

2018

21-
==== unreachableDeclarations.ts (18 errors) ====
19+
==== unreachableDeclarations.ts (16 errors) ====
2220
function func1() {
2321
aFunc();
2422

@@ -37,12 +35,10 @@ unreachableDeclarations.ts(84,2): error TS1235: A namespace declaration is only
3735

3836
enum EnumA { Value }
3937
~~~~~~~~~~~~~~~~~~~~
40-
~~~~~~~~~~~~~~~~~~~~
41-
const enum EnumB { Value }
42-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4338
!!! error TS7027: Unreachable code detected.
44-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39+
~~~~~~~~~~~~~~~~~~~~
4540
!!! error TS7027: Unreachable code detected.
41+
const enum EnumB { Value }
4642
}
4743

4844
function func2() {
@@ -78,10 +74,6 @@ unreachableDeclarations.ts(84,2): error TS1235: A namespace declaration is only
7874
}
7975

8076
const enum EnumB { Value }
81-
~~~~~~~~~~~~~~~~~~~~~~~~~~
82-
!!! error TS7027: Unreachable code detected.
83-
~~~~~~~~~~~~~~~~~~~~~~~~~~
84-
!!! error TS7027: Unreachable code detected.
8577
}
8678

8779
function func4() {

testdata/baselines/reference/submodule/compiler/unreachableDeclarations(preserveconstenums=false).errors.txt.diff

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
unreachableDeclarations.ts(21,17): error TS2450: Enum 'EnumA' used before its declaration.
88
unreachableDeclarations.ts(29,5): error TS7027: Unreachable code detected.
99
+unreachableDeclarations.ts(29,5): error TS7027: Unreachable code detected.
10-
+unreachableDeclarations.ts(43,5): error TS7027: Unreachable code detected.
11-
+unreachableDeclarations.ts(43,5): error TS7027: Unreachable code detected.
1210
unreachableDeclarations.ts(49,17): error TS2449: Class 'ClassA' used before its declaration.
1311
unreachableDeclarations.ts(57,5): error TS7027: Unreachable code detected.
1412
+unreachableDeclarations.ts(57,5): error TS7027: Unreachable code detected.
@@ -22,25 +20,20 @@
2220

2321

2422
-==== unreachableDeclarations.ts (12 errors) ====
25-
+==== unreachableDeclarations.ts (18 errors) ====
23+
+==== unreachableDeclarations.ts (16 errors) ====
2624
function func1() {
2725
aFunc();
2826

29-
@@= skipped -30, +36 lines =@@
30-
27+
@@= skipped -31, +35 lines =@@
3128
enum EnumA { Value }
3229
~~~~~~~~~~~~~~~~~~~~
33-
-!!! error TS7027: Unreachable code detected.
30+
!!! error TS7027: Unreachable code detected.
3431
+ ~~~~~~~~~~~~~~~~~~~~
35-
const enum EnumB { Value }
36-
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37-
+!!! error TS7027: Unreachable code detected.
38-
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3932
+!!! error TS7027: Unreachable code detected.
33+
const enum EnumB { Value }
4034
}
4135

42-
function func2() {
43-
@@= skipped -21, +25 lines =@@
36+
@@= skipped -20, +22 lines =@@
4437
enum EnumA { Value }
4538
~~~~~~~~~~~~~~~~~~~~
4639
!!! error TS7027: Unreachable code detected.
@@ -49,18 +42,7 @@
4942
}
5043

5144
function func3() {
52-
@@= skipped -14, +16 lines =@@
53-
}
54-
55-
const enum EnumB { Value }
56-
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
57-
+!!! error TS7027: Unreachable code detected.
58-
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
59-
+!!! error TS7027: Unreachable code detected.
60-
}
61-
62-
function func4() {
63-
@@= skipped -19, +23 lines =@@
45+
@@= skipped -33, +35 lines =@@
6446
class ClassA { static Value = 1234; }
6547
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6648
!!! error TS7027: Unreachable code detected.

0 commit comments

Comments
 (0)