Add a test case related to spreading objects (#57642)

This commit is contained in:
Mateusz Burzyński 2024-03-05 00:53:41 +01:00 committed by GitHub
parent 3b1b82a6bf
commit 0f6f7c308a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,37 @@
//// [tests/cases/compiler/spreadObjectNoCircular1.ts] ////
=== spreadObjectNoCircular1.ts ===
type Box = {
>Box : Symbol(Box, Decl(spreadObjectNoCircular1.ts, 0, 0))
content?: Foo | Box;
>content : Symbol(content, Decl(spreadObjectNoCircular1.ts, 0, 12))
>Foo : Symbol(Foo, Decl(spreadObjectNoCircular1.ts, 4, 21))
>Box : Symbol(Box, Decl(spreadObjectNoCircular1.ts, 0, 0))
};
declare const b: Box;
>b : Symbol(b, Decl(spreadObjectNoCircular1.ts, 4, 13))
>Box : Symbol(Box, Decl(spreadObjectNoCircular1.ts, 0, 0))
class Foo {
>Foo : Symbol(Foo, Decl(spreadObjectNoCircular1.ts, 4, 21))
get foo() {
>foo : Symbol(Foo.foo, Decl(spreadObjectNoCircular1.ts, 6, 11))
return {
content: this as Foo | Box,
>content : Symbol(content, Decl(spreadObjectNoCircular1.ts, 8, 12))
>this : Symbol(Foo, Decl(spreadObjectNoCircular1.ts, 4, 21))
>Foo : Symbol(Foo, Decl(spreadObjectNoCircular1.ts, 4, 21))
>Box : Symbol(Box, Decl(spreadObjectNoCircular1.ts, 0, 0))
...b,
>b : Symbol(b, Decl(spreadObjectNoCircular1.ts, 4, 13))
};
}
}

View File

@ -0,0 +1,35 @@
//// [tests/cases/compiler/spreadObjectNoCircular1.ts] ////
=== spreadObjectNoCircular1.ts ===
type Box = {
>Box : { content?: Foo | Box | undefined; }
content?: Foo | Box;
>content : Foo | Box | undefined
};
declare const b: Box;
>b : Box
class Foo {
>Foo : Foo
get foo() {
>foo : { content: Foo | Box; }
return {
>{ content: this as Foo | Box, ...b, } : { content: Foo | Box; }
content: this as Foo | Box,
>content : Foo | Box
>this as Foo | Box : Foo | Box
>this : this
...b,
>b : Box
};
}
}

View File

@ -0,0 +1,17 @@
// @strict: true
// @noEmit: true
type Box = {
content?: Foo | Box;
};
declare const b: Box;
class Foo {
get foo() {
return {
content: this as Foo | Box,
...b,
};
}
}