forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure enum members syntactically determinable to be strings do not g…
…et reverse mappings (microsoft#57686) Co-authored-by: frigus02 <[email protected]> Co-authored-by: Jan Kühle <[email protected]>
- Loading branch information
1 parent
ac8eb2c
commit f9ef943
Showing
13 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...selines/reference/computedEnumMemberSyntacticallyString(isolatedmodules=false).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
computedEnumMemberSyntacticallyString.ts(4,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(5,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(6,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(7,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(8,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
|
||
|
||
==== computedEnumMemberSyntacticallyString.ts (5 errors) ==== | ||
const BAR = 2..toFixed(0); | ||
|
||
enum Foo { | ||
A = `${BAR}`, | ||
~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
B = "2" + BAR, | ||
~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
C = (`${BAR}`), | ||
~~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
D = (`${BAR}}`) as string, | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
E = `${BAR}`!, | ||
~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/computedEnumMemberSyntacticallyString(isolatedmodules=false).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//// [tests/cases/compiler/computedEnumMemberSyntacticallyString.ts] //// | ||
|
||
//// [computedEnumMemberSyntacticallyString.ts] | ||
const BAR = 2..toFixed(0); | ||
|
||
enum Foo { | ||
A = `${BAR}`, | ||
B = "2" + BAR, | ||
C = (`${BAR}`), | ||
D = (`${BAR}}`) as string, | ||
E = `${BAR}`!, | ||
} | ||
|
||
|
||
//// [computedEnumMemberSyntacticallyString.js] | ||
const BAR = 2..toFixed(0); | ||
var Foo; | ||
(function (Foo) { | ||
Foo["A"] = `${BAR}`; | ||
Foo["B"] = "2" + BAR; | ||
Foo["C"] = (`${BAR}`); | ||
Foo["D"] = (`${BAR}}`); | ||
Foo["E"] = `${BAR}`; | ||
})(Foo || (Foo = {})); |
28 changes: 28 additions & 0 deletions
28
...aselines/reference/computedEnumMemberSyntacticallyString(isolatedmodules=true).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
computedEnumMemberSyntacticallyString.ts(4,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(5,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(6,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(7,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
computedEnumMemberSyntacticallyString.ts(8,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
|
||
|
||
==== computedEnumMemberSyntacticallyString.ts (5 errors) ==== | ||
const BAR = 2..toFixed(0); | ||
|
||
enum Foo { | ||
A = `${BAR}`, | ||
~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
B = "2" + BAR, | ||
~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
C = (`${BAR}`), | ||
~~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
D = (`${BAR}}`) as string, | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
E = `${BAR}`!, | ||
~~~~~~~~~ | ||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values. | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/computedEnumMemberSyntacticallyString(isolatedmodules=true).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//// [tests/cases/compiler/computedEnumMemberSyntacticallyString.ts] //// | ||
|
||
//// [computedEnumMemberSyntacticallyString.ts] | ||
const BAR = 2..toFixed(0); | ||
|
||
enum Foo { | ||
A = `${BAR}`, | ||
B = "2" + BAR, | ||
C = (`${BAR}`), | ||
D = (`${BAR}}`) as string, | ||
E = `${BAR}`!, | ||
} | ||
|
||
|
||
//// [computedEnumMemberSyntacticallyString.js] | ||
const BAR = 2..toFixed(0); | ||
var Foo; | ||
(function (Foo) { | ||
Foo["A"] = `${BAR}`; | ||
Foo["B"] = "2" + BAR; | ||
Foo["C"] = (`${BAR}`); | ||
Foo["D"] = (`${BAR}}`); | ||
Foo["E"] = `${BAR}`; | ||
})(Foo || (Foo = {})); |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//// [tests/cases/compiler/computedEnumMemberSyntacticallyString2.ts] //// | ||
|
||
//// [foo.ts] | ||
import { BAR } from './bar'; | ||
enum Foo { A = `${BAR}` } | ||
|
||
//// [bar.ts] | ||
export const BAR = 'bar'; | ||
|
||
//// [bar.js] | ||
export const BAR = 'bar'; | ||
//// [foo.js] | ||
import { BAR } from './bar'; | ||
var Foo; | ||
(function (Foo) { | ||
Foo["A"] = "bar"; | ||
})(Foo || (Foo = {})); |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//// [tests/cases/compiler/computedEnumMemberSyntacticallyString2.ts] //// | ||
|
||
//// [foo.ts] | ||
import { BAR } from './bar'; | ||
enum Foo { A = `${BAR}` } | ||
|
||
//// [bar.ts] | ||
export const BAR = 'bar'; | ||
|
||
//// [bar.js] | ||
export const BAR = 'bar'; | ||
//// [foo.js] | ||
import { BAR } from './bar'; | ||
var Foo; | ||
(function (Foo) { | ||
Foo["A"] = "bar"; | ||
})(Foo || (Foo = {})); |
6 changes: 6 additions & 0 deletions
6
...spile/Syntactically string but non-evaluatable enum members do not get reverse mapping.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...ically string but non-evaluatable enum members do not get reverse mapping.oldTranspile.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
tests/cases/compiler/computedEnumMemberSyntacticallyString.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @isolatedModules: true,false | ||
// @noTypesAndSymbols: true | ||
// @target: esnext | ||
|
||
const BAR = 2..toFixed(0); | ||
|
||
enum Foo { | ||
A = `${BAR}`, | ||
B = "2" + BAR, | ||
C = (`${BAR}`), | ||
D = (`${BAR}}`) as string, | ||
E = `${BAR}`!, | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/cases/compiler/computedEnumMemberSyntacticallyString2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// @isolatedModules: true,false | ||
// @noTypesAndSymbols: true | ||
// @target: esnext | ||
|
||
// @filename: ./foo.ts | ||
import { BAR } from './bar'; | ||
enum Foo { A = `${BAR}` } | ||
|
||
// @filename: ./bar.ts | ||
export const BAR = 'bar'; |