mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Test:Unknown properties are assignable to Object in union
Add test and accept baselines
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
//// [unknownPropertiesAreAssignableToObjectUnion.ts]
|
||||
const x: Object | string = { x: 0 };
|
||||
const y: Object | undefined = { x: 0 };
|
||||
|
||||
|
||||
//// [unknownPropertiesAreAssignableToObjectUnion.js]
|
||||
var x = { x: 0 };
|
||||
var y = { x: 0 };
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/unknownPropertiesAreAssignableToObjectUnion.ts ===
|
||||
const x: Object | string = { x: 0 };
|
||||
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 0, 5))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 0, 28))
|
||||
|
||||
const y: Object | undefined = { x: 0 };
|
||||
>y : Symbol(y, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 1, 5))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 1, 31))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/unknownPropertiesAreAssignableToObjectUnion.ts ===
|
||||
const x: Object | string = { x: 0 };
|
||||
>x : string | Object
|
||||
>Object : Object
|
||||
>{ x: 0 } : { x: number; }
|
||||
>x : number
|
||||
>0 : 0
|
||||
|
||||
const y: Object | undefined = { x: 0 };
|
||||
>y : Object | undefined
|
||||
>Object : Object
|
||||
>{ x: 0 } : { x: number; }
|
||||
>x : number
|
||||
>0 : 0
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// @strictNullChecks: true
|
||||
const x: Object | string = { x: 0 };
|
||||
const y: Object | undefined = { x: 0 };
|
||||
Reference in New Issue
Block a user