38 lines
2 KiB
Text
38 lines
2 KiB
Text
=== tests/cases/conformance/expressions/functions/contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts ===
|
|
declare function foo(x: (y: string) => (y2: number) => void);
|
|
>foo : Symbol(foo, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 0, 0))
|
|
>x : Symbol(x, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 0, 21))
|
|
>y : Symbol(y, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 0, 25))
|
|
>y2 : Symbol(y2, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 0, 40))
|
|
|
|
// Contextually type the parameter even if there is a return annotation
|
|
foo((y): (y2: number) => void => {
|
|
>foo : Symbol(foo, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 0, 0))
|
|
>y : Symbol(y, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 3, 5))
|
|
>y2 : Symbol(y2, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 3, 10))
|
|
|
|
var z = y.charAt(0); // Should be string
|
|
>z : Symbol(z, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 4, 7))
|
|
>y.charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
|
|
>y : Symbol(y, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 3, 5))
|
|
>charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
|
|
|
|
return null;
|
|
});
|
|
|
|
foo((y: string) => {
|
|
>foo : Symbol(foo, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 0, 0))
|
|
>y : Symbol(y, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 8, 5))
|
|
|
|
return y2 => {
|
|
>y2 : Symbol(y2, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 9, 10))
|
|
|
|
var z = y2.toFixed(); // Should be string
|
|
>z : Symbol(z, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 10, 11))
|
|
>y2.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, 463, 37))
|
|
>y2 : Symbol(y2, Decl(contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts, 9, 10))
|
|
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, 463, 37))
|
|
|
|
return 0;
|
|
};
|
|
});
|