TypeScript/tests/baselines/reference/assignmentCompatBug5.errors.txt

36 lines
2.1 KiB
Plaintext

tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
Property 'a' is missing in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
Types of parameters 's' and 'n' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
Type 'void' is not assignable to type 'number'.
==== tests/cases/compiler/assignmentCompatBug5.ts (4 errors) ====
function foo1(x: { a: number; }) { }
foo1({ b: 5 });
~~~~~~~~
!!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
!!! error TS2345: Property 'a' is missing in type '{ b: number; }'.
function foo2(x: number[]) { }
foo2(["s", "t"]);
~~~~~~~~~~
!!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
function foo3(x: (n: number) =>number) { };
foo3((s:string) => { });
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
!!! error TS2345: Types of parameters 's' and 'n' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
foo3((n) => { return; });
~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.