You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We do this so the name is reasonable for users; however it is very rare for this symbol name to appear anywhere user-facing, as the result signature is used only for contextual typing
Copy file name to clipboardExpand all lines: tests/baselines/reference/contextualTyping.errors.txt
+8-1
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,14 @@
1
+
tests/cases/compiler/contextualTyping.ts(36,5): error TS2322: Type '(n: string | number) => string | number' is not assignable to type '{ (n: number): number; (s1: string): number; }'.
2
+
Type 'string | number' is not assignable to type 'number'.
3
+
Type 'string' is not assignable to type 'number'.
1
4
tests/cases/compiler/contextualTyping.ts(189,18): error TS2384: Overload signatures must all be ambient or non-ambient.
//• If e is a FunctionExpression or ArrowFunctionExpression with no type parameters and no parameter or return type annotations, and T is a function type with EXACTLY ONE non - generic call signature, then any inferences made for type parameters referenced by the parameters of T’s call signature are fixed(section 4.12.2) and e is processed with the contextual type T, as described in section 4.9.3.
11
+
12
+
var f2: {
13
+
(x: string, y: number): string;
14
+
<T, U>(x: T, y: U): T
15
+
};
16
+
17
+
f2 = (x, y) => { return x }
18
+
~~
19
+
!!! error TS2322: Type '<T, U>(x: string | T, y: number | U) => string | T' is not assignable to type '{ (x: string, y: number): string; <T, U>(x: T, y: U): T; }'.
20
+
!!! error TS2322: Type 'string | T' is not assignable to type 'string'.
21
+
!!! error TS2322: Type 'T' is not assignable to type 'string'.
22
+
23
+
var f3: {
24
+
<T, U>(x: T, y: U): T
25
+
(x: string, y: number): string;
26
+
};
27
+
28
+
f3 = (x, y) => { return x }
29
+
~~
30
+
!!! error TS2322: Type '<T, U>(x: string | T, y: number | U) => string | T' is not assignable to type '{ <T, U>(x: T, y: U): T; (x: string, y: number): string; }'.
31
+
!!! error TS2322: Type 'string | T' is not assignable to type 'string'.
32
+
!!! error TS2322: Type 'T' is not assignable to type 'string'.
tests/cases/conformance/types/specifyingTypes/typeLiterals/functionLiteralForOverloads.ts(3,5): error TS2322: Type '(x: string | number) => string | number' is not assignable to type '{ (x: string): string; (x: number): number; }'.
2
+
Type 'string | number' is not assignable to type 'string'.
3
+
Type 'number' is not assignable to type 'string'.
4
+
tests/cases/conformance/types/specifyingTypes/typeLiterals/functionLiteralForOverloads.ts(8,5): error TS2322: Type '<T, T>(x: string | number) => string | number' is not assignable to type '{ <T>(x: string): string; <T>(x: number): number; }'.
5
+
Type 'string | number' is not assignable to type 'string'.
0 commit comments