|
| 1 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 2 | + Type 'number' is not assignable to type 'string'. |
| 3 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(5,23): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 4 | + Type 'number' is not assignable to type 'string'. |
| 5 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(6,25): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 6 | + Type 'number' is not assignable to type 'string'. |
| 7 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(11,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. |
| 8 | + Types of property 'show' are incompatible. |
| 9 | + Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 10 | + Type 'number' is not assignable to type 'string'. |
| 11 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. |
| 12 | + Type 'number' is not assignable to type 'string'. |
| 13 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. |
| 14 | + Type 'number' is not assignable to type 'string'. |
| 15 | +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. |
| 16 | + |
| 17 | + |
| 18 | +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (7 errors) ==== |
| 19 | + interface Show { |
| 20 | + show: (x: number) => string; |
| 21 | + } |
| 22 | + function f({ show: showRename = v => v }: Show) {} |
| 23 | + ~~~~~~~~~~ |
| 24 | +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 25 | +!!! error TS2322: Type 'number' is not assignable to type 'string'. |
| 26 | + function f2({ "show": showRename = v => v }: Show) {} |
| 27 | + ~~~~~~~~~~ |
| 28 | +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 29 | +!!! error TS2322: Type 'number' is not assignable to type 'string'. |
| 30 | + function f3({ ["show"]: showRename = v => v }: Show) {} |
| 31 | + ~~~~~~~~~~ |
| 32 | +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 33 | +!!! error TS2322: Type 'number' is not assignable to type 'string'. |
| 34 | + |
| 35 | + interface Nested { |
| 36 | + nested: Show |
| 37 | + } |
| 38 | + function ff({ nested: nestedRename = { show: v => v } }: Nested) {} |
| 39 | + ~~~~~~~~~~~~ |
| 40 | +!!! error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. |
| 41 | +!!! error TS2322: Types of property 'show' are incompatible. |
| 42 | +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. |
| 43 | +!!! error TS2322: Type 'number' is not assignable to type 'string'. |
| 44 | + |
| 45 | + interface StringIdentity { |
| 46 | + stringIdentity(s: string): string; |
| 47 | + } |
| 48 | + let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; |
| 49 | + ~~ |
| 50 | +!!! error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. |
| 51 | +!!! error TS2322: Type 'number' is not assignable to type 'string'. |
| 52 | + |
| 53 | + interface Tuples { |
| 54 | + prop: [string, number]; |
| 55 | + } |
| 56 | + function g({ prop = [101, 1234] }: Tuples) {} |
| 57 | + ~~~~ |
| 58 | +!!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. |
| 59 | +!!! error TS2322: Type 'number' is not assignable to type 'string'. |
| 60 | + |
| 61 | + interface StringUnion { |
| 62 | + prop: "foo" | "bar"; |
| 63 | + } |
| 64 | + function h({ prop = "baz" }: StringUnion) {} |
| 65 | + ~~~~ |
| 66 | +!!! error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. |
| 67 | + |
0 commit comments