Skip to content

Commit 4b15830

Browse files
authored
Add an extra test for as const satisfies with a mutable array (#55522)
1 parent 11b2313 commit 4b15830

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_asConstArrays.ts] ////
2+
3+
=== typeSatisfaction_asConstArrays.ts ===
4+
// with readonly array
5+
const arr1 = [1, 2, 3] as const satisfies readonly unknown[]
6+
>arr1 : Symbol(arr1, Decl(typeSatisfaction_asConstArrays.ts, 1, 5))
7+
>const : Symbol(const)
8+
9+
// with mutable array
10+
const arr2 = [1, 2, 3] as const satisfies unknown[]
11+
>arr2 : Symbol(arr2, Decl(typeSatisfaction_asConstArrays.ts, 4, 5))
12+
>const : Symbol(const)
13+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_asConstArrays.ts] ////
2+
3+
=== typeSatisfaction_asConstArrays.ts ===
4+
// with readonly array
5+
const arr1 = [1, 2, 3] as const satisfies readonly unknown[]
6+
>arr1 : readonly [1, 2, 3]
7+
>[1, 2, 3] as const satisfies readonly unknown[] : readonly [1, 2, 3]
8+
>[1, 2, 3] as const : readonly [1, 2, 3]
9+
>[1, 2, 3] : readonly [1, 2, 3]
10+
>1 : 1
11+
>2 : 2
12+
>3 : 3
13+
14+
// with mutable array
15+
const arr2 = [1, 2, 3] as const satisfies unknown[]
16+
>arr2 : [1, 2, 3]
17+
>[1, 2, 3] as const satisfies unknown[] : [1, 2, 3]
18+
>[1, 2, 3] as const : [1, 2, 3]
19+
>[1, 2, 3] : [1, 2, 3]
20+
>1 : 1
21+
>2 : 2
22+
>3 : 3
23+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
// with readonly array
5+
const arr1 = [1, 2, 3] as const satisfies readonly unknown[]
6+
7+
// with mutable array
8+
const arr2 = [1, 2, 3] as const satisfies unknown[]

0 commit comments

Comments
 (0)