23 lines
No EOL
1.7 KiB
Text
23 lines
No EOL
1.7 KiB
Text
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
|
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,5): error TS2345: 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'.
|
|
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
|
Property 'id' is missing in type '{ name: string; }'.
|
|
|
|
|
|
==== tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts (3 errors) ====
|
|
function foo(x: { id: number; name?: string; }): void;
|
|
~~~
|
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
|
foo({ id: 1234 }); // Ok
|
|
foo({ id: 1234, name: "hello" }); // Ok
|
|
foo({ id: 1234, name: false }); // Error, name of wrong type
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
|
!!! error TS2345: Types of property 'name' are incompatible.
|
|
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
|
foo({ name: "hello" }); // Error, id required but missing
|
|
~~~~~~~~~~~~~~~~~
|
|
!!! error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
|
!!! error TS2345: Property 'id' is missing in type '{ name: string; }'. |