2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts (4 errors) ====
|
|
|
|
interface I {
|
|
|
|
value: string;
|
|
|
|
toString: (t: string) => string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function f2(args: I) { }
|
|
|
|
|
|
|
|
f2({ hello: 1 }) // error
|
2014-07-25 02:00:03 +02:00
|
|
|
~~~~~~~~~~~~
|
|
|
|
!!! Argument type '{ hello: number; }' is not assignable to parameter type 'I'.
|
|
|
|
!!! Property 'value' is missing in type '{ hello: number; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
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
|
2014-07-25 02:00:03 +02:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
!!! Argument type '{ toString: (s: string) => string; }' is not assignable to parameter type 'I'.
|
|
|
|
!!! Property 'value' is missing in type '{ toString: (s: string) => string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
f2({ toString: (s: string) => s }) // error, missing property value from ArgsString
|
2014-07-25 02:00:03 +02:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
!!! Argument type '{ toString: (s: string) => string; }' is not assignable to parameter type 'I'.
|
|
|
|
!!! Property 'value' is missing in type '{ toString: (s: string) => string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
f2({ value: '', toString: (s) => s.uhhh }) // error
|
|
|
|
~~~~
|
|
|
|
!!! Property 'uhhh' does not exist on type 'string'.
|