TypeScript/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt
2014-07-24 19:39:50 -07:00

25 lines
1.3 KiB
Plaintext

==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts (4 errors) ====
interface I {
value: string;
toString: (t: string) => string;
}
function f2(args: I) { }
f2({ hello: 1 }) // error
~~~~~~~~~~~~
!!! Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'.
!!! Property 'value' is missing in type '{ hello: number; }'.
f2({ value: '' }) // missing toString satisfied by Object's member
f2({ value: '', what: 1 }) // missing toString satisfied by Object's member
f2({ toString: (s) => s }) // error, missing property value from ArgsString
~~~~~~~~~~~~~~~~~~~~~~
!!! Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'.
!!! Property 'value' is missing in type '{ toString: (s: string) => string; }'.
f2({ toString: (s: string) => s }) // error, missing property value from ArgsString
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'.
!!! Property 'value' is missing in type '{ toString: (s: string) => string; }'.
f2({ value: '', toString: (s) => s.uhhh }) // error
~~~~
!!! Property 'uhhh' does not exist on type 'string'.