-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Pick PR #58786 (Fixed declaration emit crash relate...) into releas…
…e-5.5 (#58853) Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
Showing
25 changed files
with
663 additions
and
2 deletions.
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
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/declarationEmitComputedPropertyNameEnum1.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,34 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum1.ts] //// | ||
|
||
//// [type.ts] | ||
export enum Enum { | ||
A = "a", | ||
B = "b" | ||
} | ||
|
||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
|
||
//// [index.ts] | ||
import { type Type } from "./type"; | ||
|
||
export const foo = { ...({} as Type) }; | ||
|
||
|
||
|
||
|
||
//// [type.d.ts] | ||
export declare enum Enum { | ||
A = "a", | ||
B = "b" | ||
} | ||
export type Type = { | ||
x?: { | ||
[Enum.A]: 0; | ||
}; | ||
}; | ||
//// [index.d.ts] | ||
export declare const foo: { | ||
x?: { | ||
a: 0; | ||
}; | ||
}; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/declarationEmitComputedPropertyNameEnum1.symbols
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,29 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum1.ts] //// | ||
|
||
=== type.ts === | ||
export enum Enum { | ||
>Enum : Symbol(Enum, Decl(type.ts, 0, 0)) | ||
|
||
A = "a", | ||
>A : Symbol(Enum.A, Decl(type.ts, 0, 18)) | ||
|
||
B = "b" | ||
>B : Symbol(Enum.B, Decl(type.ts, 1, 10)) | ||
} | ||
|
||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
>Type : Symbol(Type, Decl(type.ts, 3, 1)) | ||
>x : Symbol(x, Decl(type.ts, 5, 20)) | ||
>[Enum.A] : Symbol([Enum.A], Decl(type.ts, 5, 26)) | ||
>Enum.A : Symbol(Enum.A, Decl(type.ts, 0, 18)) | ||
>Enum : Symbol(Enum, Decl(type.ts, 0, 0)) | ||
>A : Symbol(Enum.A, Decl(type.ts, 0, 18)) | ||
|
||
=== index.ts === | ||
import { type Type } from "./type"; | ||
>Type : Symbol(Type, Decl(index.ts, 0, 8)) | ||
|
||
export const foo = { ...({} as Type) }; | ||
>foo : Symbol(foo, Decl(index.ts, 2, 12)) | ||
>Type : Symbol(Type, Decl(index.ts, 0, 8)) | ||
|
51 changes: 51 additions & 0 deletions
51
tests/baselines/reference/declarationEmitComputedPropertyNameEnum1.types
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,51 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum1.ts] //// | ||
|
||
=== type.ts === | ||
export enum Enum { | ||
>Enum : Enum | ||
> : ^^^^ | ||
|
||
A = "a", | ||
>A : Enum.A | ||
> : ^^^^^^ | ||
>"a" : "a" | ||
> : ^^^ | ||
|
||
B = "b" | ||
>B : Enum.B | ||
> : ^^^^^^ | ||
>"b" : "b" | ||
> : ^^^ | ||
} | ||
|
||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
>Type : Type | ||
> : ^^^^ | ||
>x : { a: 0; } | undefined | ||
> : ^^^^^ ^^^^^^^^^^^^^^^ | ||
>[Enum.A] : 0 | ||
> : ^ | ||
>Enum.A : Enum.A | ||
> : ^^^^^^ | ||
>Enum : typeof Enum | ||
> : ^^^^^^^^^^^ | ||
>A : Enum.A | ||
> : ^^^^^^ | ||
|
||
=== index.ts === | ||
import { type Type } from "./type"; | ||
>Type : any | ||
> : ^^^ | ||
|
||
export const foo = { ...({} as Type) }; | ||
>foo : { x?: { a: 0; }; } | ||
> : ^^^^^^ ^^^ | ||
>{ ...({} as Type) } : { x?: { a: 0; }; } | ||
> : ^^^^^^ ^^^ | ||
>({} as Type) : Type | ||
> : ^^^^ | ||
>{} as Type : Type | ||
> : ^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.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,16 @@ | ||
type.ts(1,28): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. | ||
type.ts(1,29): error TS2304: Cannot find name 'Enum'. | ||
|
||
|
||
==== type.ts (2 errors) ==== | ||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
~~~~~~~~ | ||
!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. | ||
~~~~ | ||
!!! error TS2304: Cannot find name 'Enum'. | ||
|
||
==== index.ts (0 errors) ==== | ||
import { type Type } from "./type"; | ||
|
||
export const foo = { ...({} as Type) }; | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.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,23 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum2.ts] //// | ||
|
||
//// [type.ts] | ||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
|
||
//// [index.ts] | ||
import { type Type } from "./type"; | ||
|
||
export const foo = { ...({} as Type) }; | ||
|
||
|
||
|
||
|
||
//// [type.d.ts] | ||
export type Type = { | ||
x?: {}; | ||
}; | ||
//// [index.d.ts] | ||
export declare const foo: { | ||
x?: { | ||
[Enum.A]: 0; | ||
}; | ||
}; |
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.symbols
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,16 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum2.ts] //// | ||
|
||
=== type.ts === | ||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
>Type : Symbol(Type, Decl(type.ts, 0, 0)) | ||
>x : Symbol(x, Decl(type.ts, 0, 20)) | ||
>[Enum.A] : Symbol([Enum.A], Decl(type.ts, 0, 26)) | ||
|
||
=== index.ts === | ||
import { type Type } from "./type"; | ||
>Type : Symbol(Type, Decl(index.ts, 0, 8)) | ||
|
||
export const foo = { ...({} as Type) }; | ||
>foo : Symbol(foo, Decl(index.ts, 2, 12)) | ||
>Type : Symbol(Type, Decl(index.ts, 0, 8)) | ||
|
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/declarationEmitComputedPropertyNameEnum2.types
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,34 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum2.ts] //// | ||
|
||
=== type.ts === | ||
export type Type = { x?: { [Enum.A]: 0 } }; | ||
>Type : Type | ||
> : ^^^^ | ||
>x : {} | undefined | ||
> : ^^^^^^^^^^^^^^ | ||
>[Enum.A] : 0 | ||
> : ^ | ||
>Enum.A : any | ||
> : ^^^ | ||
>Enum : any | ||
> : ^^^ | ||
>A : any | ||
> : ^^^ | ||
|
||
=== index.ts === | ||
import { type Type } from "./type"; | ||
>Type : any | ||
> : ^^^ | ||
|
||
export const foo = { ...({} as Type) }; | ||
>foo : { x?: { [Enum.A]: 0; }; } | ||
> : ^^^^^^ ^^^ | ||
>{ ...({} as Type) } : { x?: { [Enum.A]: 0; }; } | ||
> : ^^^^^^ ^^^ | ||
>({} as Type) : Type | ||
> : ^^^^ | ||
>{} as Type : Type | ||
> : ^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.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,22 @@ | ||
type.ts(7,28): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. | ||
type.ts(7,28): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. | ||
|
||
|
||
==== type.ts (2 errors) ==== | ||
export namespace Foo { | ||
export enum Enum { | ||
A = "a", | ||
B = "b", | ||
} | ||
} | ||
export type Type = { x?: { [Foo.Enum]: 0 } }; | ||
~~~~~~~~~~ | ||
!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. | ||
~~~~~~~~~~ | ||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. | ||
|
||
==== index.ts (0 errors) ==== | ||
import { type Type } from "./type"; | ||
|
||
export const foo = { ...({} as Type) }; | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.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,33 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum3.ts] //// | ||
|
||
//// [type.ts] | ||
export namespace Foo { | ||
export enum Enum { | ||
A = "a", | ||
B = "b", | ||
} | ||
} | ||
export type Type = { x?: { [Foo.Enum]: 0 } }; | ||
|
||
//// [index.ts] | ||
import { type Type } from "./type"; | ||
|
||
export const foo = { ...({} as Type) }; | ||
|
||
|
||
|
||
|
||
//// [type.d.ts] | ||
export declare namespace Foo { | ||
enum Enum { | ||
A = "a", | ||
B = "b" | ||
} | ||
} | ||
export type Type = { | ||
x?: {}; | ||
}; | ||
//// [index.d.ts] | ||
export declare const foo: { | ||
x?: {}; | ||
}; |
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.symbols
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,32 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum3.ts] //// | ||
|
||
=== type.ts === | ||
export namespace Foo { | ||
>Foo : Symbol(Foo, Decl(type.ts, 0, 0)) | ||
|
||
export enum Enum { | ||
>Enum : Symbol(Enum, Decl(type.ts, 0, 22)) | ||
|
||
A = "a", | ||
>A : Symbol(Enum.A, Decl(type.ts, 1, 20)) | ||
|
||
B = "b", | ||
>B : Symbol(Enum.B, Decl(type.ts, 2, 12)) | ||
} | ||
} | ||
export type Type = { x?: { [Foo.Enum]: 0 } }; | ||
>Type : Symbol(Type, Decl(type.ts, 5, 1)) | ||
>x : Symbol(x, Decl(type.ts, 6, 20)) | ||
>[Foo.Enum] : Symbol([Foo.Enum], Decl(type.ts, 6, 26)) | ||
>Foo.Enum : Symbol(Foo.Enum, Decl(type.ts, 0, 22)) | ||
>Foo : Symbol(Foo, Decl(type.ts, 0, 0)) | ||
>Enum : Symbol(Foo.Enum, Decl(type.ts, 0, 22)) | ||
|
||
=== index.ts === | ||
import { type Type } from "./type"; | ||
>Type : Symbol(Type, Decl(index.ts, 0, 8)) | ||
|
||
export const foo = { ...({} as Type) }; | ||
>foo : Symbol(foo, Decl(index.ts, 2, 12)) | ||
>Type : Symbol(Type, Decl(index.ts, 0, 8)) | ||
|
55 changes: 55 additions & 0 deletions
55
tests/baselines/reference/declarationEmitComputedPropertyNameEnum3.types
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,55 @@ | ||
//// [tests/cases/compiler/declarationEmitComputedPropertyNameEnum3.ts] //// | ||
|
||
=== type.ts === | ||
export namespace Foo { | ||
>Foo : typeof Foo | ||
> : ^^^^^^^^^^ | ||
|
||
export enum Enum { | ||
>Enum : Enum | ||
> : ^^^^ | ||
|
||
A = "a", | ||
>A : Enum.A | ||
> : ^^^^^^ | ||
>"a" : "a" | ||
> : ^^^ | ||
|
||
B = "b", | ||
>B : Enum.B | ||
> : ^^^^^^ | ||
>"b" : "b" | ||
> : ^^^ | ||
} | ||
} | ||
export type Type = { x?: { [Foo.Enum]: 0 } }; | ||
>Type : Type | ||
> : ^^^^ | ||
>x : {} | undefined | ||
> : ^^^^^^^^^^^^^^ | ||
>[Foo.Enum] : 0 | ||
> : ^ | ||
>Foo.Enum : typeof Foo.Enum | ||
> : ^^^^^^^^^^^^^^^ | ||
>Foo : typeof Foo | ||
> : ^^^^^^^^^^ | ||
>Enum : typeof Foo.Enum | ||
> : ^^^^^^^^^^^^^^^ | ||
|
||
=== index.ts === | ||
import { type Type } from "./type"; | ||
>Type : any | ||
> : ^^^ | ||
|
||
export const foo = { ...({} as Type) }; | ||
>foo : { x?: {}; } | ||
> : ^^^^^^ ^^^ | ||
>{ ...({} as Type) } : { x?: {}; } | ||
> : ^^^^^^ ^^^ | ||
>({} as Type) : Type | ||
> : ^^^^ | ||
>{} as Type : Type | ||
> : ^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
Oops, something went wrong.