TypeScript/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt
2014-09-12 13:35:07 -07:00

34 lines
2.3 KiB
Plaintext

tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'.
Property 'value' is missing in type '{ hello: number; }'.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(11,4): error TS2345: 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; }'.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(12,4): error TS2345: 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; }'.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(13,36): error TS2339: Property 'uhhh' does not exist on type 'string'.
==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts (4 errors) ====
interface I {
value: string;
toString: (t: string) => string;
}
function f2(args: I) { }
f2({ hello: 1 }) // error
~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'.
!!! error TS2345: 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
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'.
!!! error TS2345: Property 'value' is missing in type '{ toString: (s: string) => string; }'.
f2({ toString: (s: string) => s }) // error, missing property value from ArgsString
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'.
!!! error TS2345: Property 'value' is missing in type '{ toString: (s: string) => string; }'.
f2({ value: '', toString: (s) => s.uhhh }) // error
~~~~
!!! error TS2339: Property 'uhhh' does not exist on type 'string'.