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

15 lines
961 B
Text
Raw Normal View History

2014-07-13 01:04:16 +02:00
==== tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts (3 errors) ====
function foo(x: { id: number; name?: string; }): void;
2014-07-31 01:27:13 +02:00
~~~
!!! Function implementation is missing or not immediately following the declaration.
2014-07-13 01:04:16 +02:00
foo({ id: 1234 }); // Ok
foo({ id: 1234, name: "hello" }); // Ok
foo({ id: 1234, name: false }); // Error, name of wrong type
~~~~~~~~~~~~~~~~~~~~~~~~~
2014-07-25 04:39:50 +02:00
!!! Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
!!! Types of property 'name' are incompatible:
!!! Type 'boolean' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
foo({ name: "hello" }); // Error, id required but missing
~~~~~~~~~~~~~~~~~
2014-07-25 04:39:50 +02:00
!!! Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
!!! Property 'id' is missing in type '{ name: string; }'.