// @strict: true // @target: es6 // #6611 export interface A { value: a; } function fn(values: A, value: a) : void { } declare let handlers: A<(value: number) => void>; fn(handlers, value => alert(value)); // #21382 interface BaseProps { initialValues: T; nextValues: (cur: T) => T; } declare class Component

{ constructor(props: P); props: P; } declare class GenericComponent extends Component> { iv: Values; } new GenericComponent({ initialValues: 12, nextValues: val => 12 }); // #22149 declare function useStringOrNumber(t: T, useIt: T extends string ? ((s: string) => void) : ((n: number) => void)): void; useStringOrNumber("", foo => {}); // #25299 type ActionType

= string & { attachPayloadTypeHack?: P & never } type Handler = P extends void ? (state: S) => S : (state: S, payload: P) => S interface ActionHandler { actionType: ActionType

handler: Handler } declare function handler(actionType: ActionType

, handler: Handler): ActionHandler declare function createReducer( defaultState: S, ...actionHandlers: ActionHandler[] ): any interface AppState { dummy: string } const defaultState: AppState = { dummy: '' } const NON_VOID_ACTION: ActionType = 'NON_VOID_ACTION' , VOID_ACTION: ActionType = 'VOID_ACTION' createReducer( defaultState, handler(NON_VOID_ACTION, (state, _payload) => state), handler(VOID_ACTION, state => state) ) // #25814 type R = { a: (x: number) => void; b: (x: string) => void; }; type O = { on

(x: P, callback: R[P]): void; }; declare var x: O; x.on('a', a => {}); // #29775 namespace N1 { declare class Component

{ constructor(props: P); } interface ComponentClass

{ new (props: P): Component

; } type CreateElementChildren

= P extends { children?: infer C } ? C extends any[] ? C : C[] : unknown; declare function createElement

( type: ComponentClass

, ...children: CreateElementChildren

): any; declare function createElement2

( type: ComponentClass

, child: CreateElementChildren

): any; class InferFunctionTypes extends Component<{children: (foo: number) => string}> {} createElement(InferFunctionTypes, (foo) => "" + foo); createElement2(InferFunctionTypes, [(foo) => "" + foo]); } // #30341 type InnerBox = { value: T; } type OuterBox = { inner: InnerBox }; type BoxConsumerFromOuterBox = T extends OuterBox ? (box: InnerBox) => void : never; declare function passContentsToFunc(outerBox: T, consumer: BoxConsumerFromOuterBox): void; declare const outerBoxOfString: OuterBox; passContentsToFunc(outerBoxOfString, box => box.value); // Repro from #32349 type DooDad = 'SOMETHING' | 'ELSE' ; class Interesting { public compiles = () : Promise => { return Promise.resolve().then(() => { if (1 < 2) { return 'SOMETHING'; } return 'ELSE'; }); }; public doesnt = () : Promise => { return Promise.resolve().then(() => { return 'ELSE'; }); }; public slightlyDifferentErrorMessage = () : Promise => { return Promise.resolve().then(() => { if (1 < 2) { return 'SOMETHING'; } return 'SOMETHING'; }); }; } // Repro from #32349 declare function invoke(f: () => T): T; let xx: 0 | 1 | 2 = invoke(() => 1); // Repro from #32416 declare function assignPartial(target: T, partial: Partial): T; let obj = { foo(bar: string) {} } assignPartial(obj, { foo(...args) {} }); // args has type [string]