Skip to content

Commit 8ab2221

Browse files
committed
Test:Unknown properties are assignable to Object in union
Add test and accept baselines
1 parent adefdc7 commit 8ab2221

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [unknownPropertiesAreAssignableToObjectUnion.ts]
2+
const x: Object | string = { x: 0 };
3+
const y: Object | undefined = { x: 0 };
4+
5+
6+
//// [unknownPropertiesAreAssignableToObjectUnion.js]
7+
var x = { x: 0 };
8+
var y = { x: 0 };
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/unknownPropertiesAreAssignableToObjectUnion.ts ===
2+
const x: Object | string = { x: 0 };
3+
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 0, 5))
4+
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
5+
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 0, 28))
6+
7+
const y: Object | undefined = { x: 0 };
8+
>y : Symbol(y, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 1, 5))
9+
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
10+
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 1, 31))
11+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/compiler/unknownPropertiesAreAssignableToObjectUnion.ts ===
2+
const x: Object | string = { x: 0 };
3+
>x : string | Object
4+
>Object : Object
5+
>{ x: 0 } : { x: number; }
6+
>x : number
7+
>0 : 0
8+
9+
const y: Object | undefined = { x: 0 };
10+
>y : Object | undefined
11+
>Object : Object
12+
>{ x: 0 } : { x: number; }
13+
>x : number
14+
>0 : 0
15+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @strictNullChecks: true
2+
const x: Object | string = { x: 0 };
3+
const y: Object | undefined = { x: 0 };

0 commit comments

Comments
 (0)