54 lines
2.1 KiB
Text
54 lines
2.1 KiB
Text
|
==== tests/cases/compiler/assignmentCompatBug2.ts (5 errors) ====
|
||
|
var b2: { b: number;} = { a: 0 }; // error
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! Type '{ a: number; }' is not assignable to type '{ b: number; }':
|
||
|
!!! Property 'b' is missing in type '{ a: number; }'.
|
||
|
|
||
|
b2 = { a: 0 }; // error
|
||
|
~~
|
||
|
!!! Type '{ a: number; }' is not assignable to type '{ b: number; }':
|
||
|
!!! Property 'b' is missing in type '{ a: number; }'.
|
||
|
|
||
|
b2 = {b: 0, a: 0 };
|
||
|
|
||
|
var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; };
|
||
|
|
||
|
b3 = {
|
||
|
f: (n) => { return 0; },
|
||
|
g: (s) => { return 0; },
|
||
|
m: 0,
|
||
|
}; // ok
|
||
|
|
||
|
b3 = {
|
||
|
~~
|
||
|
!!! Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }':
|
||
|
!!! Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
|
||
|
f: (n) => { return 0; },
|
||
|
g: (s) => { return 0; },
|
||
|
}; // error
|
||
|
|
||
|
b3 = {
|
||
|
~~
|
||
|
!!! Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }':
|
||
|
!!! Property 'g' is missing in type '{ f: (n: number) => number; m: number; }'.
|
||
|
f: (n) => { return 0; },
|
||
|
m: 0,
|
||
|
}; // error
|
||
|
|
||
|
b3 = {
|
||
|
f: (n) => { return 0; },
|
||
|
g: (s) => { return 0; },
|
||
|
m: 0,
|
||
|
n: 0,
|
||
|
k: (a) =>{ return null; },
|
||
|
}; // ok
|
||
|
|
||
|
b3 = {
|
||
|
~~
|
||
|
!!! Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }':
|
||
|
!!! Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'.
|
||
|
f: (n) => { return 0; },
|
||
|
g: (s) => { return 0; },
|
||
|
n: 0,
|
||
|
k: (a) =>{ return null; },
|
||
|
}; // error
|