32 lines
1.5 KiB
Text
32 lines
1.5 KiB
Text
=== tests/cases/conformance/types/typeRelationships/widenedTypes/arrayLiteralWidened.ts ===
|
|
// array literals are widened upon assignment according to their element type
|
|
|
|
var a = []; // any[]
|
|
>a : Symbol(a, Decl(arrayLiteralWidened.ts, 2, 3), Decl(arrayLiteralWidened.ts, 4, 3), Decl(arrayLiteralWidened.ts, 5, 3))
|
|
|
|
var a = [null, null];
|
|
>a : Symbol(a, Decl(arrayLiteralWidened.ts, 2, 3), Decl(arrayLiteralWidened.ts, 4, 3), Decl(arrayLiteralWidened.ts, 5, 3))
|
|
|
|
var a = [undefined, undefined];
|
|
>a : Symbol(a, Decl(arrayLiteralWidened.ts, 2, 3), Decl(arrayLiteralWidened.ts, 4, 3), Decl(arrayLiteralWidened.ts, 5, 3))
|
|
>undefined : Symbol(undefined)
|
|
>undefined : Symbol(undefined)
|
|
|
|
var b = [[], [null, null]]; // any[][]
|
|
>b : Symbol(b, Decl(arrayLiteralWidened.ts, 7, 3), Decl(arrayLiteralWidened.ts, 8, 3), Decl(arrayLiteralWidened.ts, 9, 3))
|
|
|
|
var b = [[], []];
|
|
>b : Symbol(b, Decl(arrayLiteralWidened.ts, 7, 3), Decl(arrayLiteralWidened.ts, 8, 3), Decl(arrayLiteralWidened.ts, 9, 3))
|
|
|
|
var b = [[undefined, undefined]];
|
|
>b : Symbol(b, Decl(arrayLiteralWidened.ts, 7, 3), Decl(arrayLiteralWidened.ts, 8, 3), Decl(arrayLiteralWidened.ts, 9, 3))
|
|
>undefined : Symbol(undefined)
|
|
>undefined : Symbol(undefined)
|
|
|
|
var c = [[[]]]; // any[][][]
|
|
>c : Symbol(c, Decl(arrayLiteralWidened.ts, 11, 3), Decl(arrayLiteralWidened.ts, 12, 3))
|
|
|
|
var c = [[[null]],[undefined]]
|
|
>c : Symbol(c, Decl(arrayLiteralWidened.ts, 11, 3), Decl(arrayLiteralWidened.ts, 12, 3))
|
|
>undefined : Symbol(undefined)
|
|
|