34 lines
No EOL
2.3 KiB
Text
34 lines
No EOL
2.3 KiB
Text
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'. |