2014-12-16 00:01:33 +01:00
|
|
|
//// [taggedTemplateContextualTyping1.ts]
|
2014-12-15 23:11:21 +01:00
|
|
|
|
2014-12-16 02:09:56 +01:00
|
|
|
type FuncType = (x: <T>(p: T) => T) => typeof x;
|
|
|
|
|
|
|
|
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, x: T): T;
|
|
|
|
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T;
|
2014-12-15 23:11:21 +01:00
|
|
|
function tempTag1<T>(...rest: any[]): T {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2014-12-16 02:09:56 +01:00
|
|
|
// If contextual typing takes place, these functions should work.
|
|
|
|
// Otherwise, the arrow functions' parameters will be typed as 'any',
|
|
|
|
// and it is an error to invoke an any-typed value with type arguments,
|
|
|
|
// so this test will error.
|
2015-01-09 01:39:47 +01:00
|
|
|
tempTag1 `${ x => { x<number>(undefined); return x; } }${ 10 }`;
|
2014-12-16 02:09:56 +01:00
|
|
|
tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`;
|
|
|
|
tempTag1 `${ x => { x<number>(undefined); return x; } }${ (y: <T>(p: T) => T) => { y<number>(undefined); return y } }${ undefined }`;
|
|
|
|
tempTag1 `${ (x: <T>(p: T) => T) => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ undefined }`;
|
2014-12-15 23:11:21 +01:00
|
|
|
|
2014-12-16 00:01:33 +01:00
|
|
|
|
|
|
|
//// [taggedTemplateContextualTyping1.js]
|
2015-01-06 00:08:17 +01:00
|
|
|
function tempTag1(...rest) {
|
2014-12-15 23:11:21 +01:00
|
|
|
return undefined;
|
|
|
|
}
|
2014-12-16 02:09:56 +01:00
|
|
|
// If contextual typing takes place, these functions should work.
|
|
|
|
// Otherwise, the arrow functions' parameters will be typed as 'any',
|
|
|
|
// and it is an error to invoke an any-typed value with type arguments,
|
|
|
|
// so this test will error.
|
2015-01-27 04:00:38 +01:00
|
|
|
tempTag1 `${x => {
|
2015-01-09 01:39:47 +01:00
|
|
|
x(undefined);
|
|
|
|
return x;
|
|
|
|
}}${10}`;
|
2015-01-27 04:00:38 +01:00
|
|
|
tempTag1 `${x => {
|
2014-12-16 02:09:56 +01:00
|
|
|
x(undefined);
|
|
|
|
return x;
|
2015-01-27 04:00:38 +01:00
|
|
|
}}${y => {
|
2014-12-16 02:09:56 +01:00
|
|
|
y(undefined);
|
|
|
|
return y;
|
|
|
|
}}${10}`;
|
2015-01-27 04:00:38 +01:00
|
|
|
tempTag1 `${x => {
|
2014-12-16 02:09:56 +01:00
|
|
|
x(undefined);
|
|
|
|
return x;
|
2015-01-24 02:28:30 +01:00
|
|
|
}}${(y) => {
|
2014-12-16 02:09:56 +01:00
|
|
|
y(undefined);
|
|
|
|
return y;
|
|
|
|
}}${undefined}`;
|
2015-01-24 02:28:30 +01:00
|
|
|
tempTag1 `${(x) => {
|
2014-12-16 02:09:56 +01:00
|
|
|
x(undefined);
|
|
|
|
return x;
|
2015-01-27 04:00:38 +01:00
|
|
|
}}${y => {
|
2014-12-16 02:09:56 +01:00
|
|
|
y(undefined);
|
|
|
|
return y;
|
|
|
|
}}${undefined}`;
|