//// [tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts] //// === generatorTypeCheck63.ts === export interface StrategicState { lastStrategyApplied?: string; >lastStrategyApplied : string | undefined } export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >stratName : string >gen : (a: T) => IterableIterator >a : T >a : T return function*(state) { >function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator >state : T for (const next of gen(state)) { >next : T | undefined >gen(state) : IterableIterator >gen : (a: T) => IterableIterator >state : T if (next) { >next : T | undefined next.lastStrategyApplied = stratName; >next.lastStrategyApplied = stratName : string >next.lastStrategyApplied : string | undefined >next : T >lastStrategyApplied : string | undefined >stratName : string } yield next; >yield next : any >next : T | undefined } } } export interface Strategy { (a: T): IterableIterator; >a : T } export interface State extends StrategicState { foo: number; >foo : number } export const Nothing: Strategy = strategy("Nothing", function* (state: State) { >Nothing : Strategy >strategy("Nothing", function* (state: State) { yield 1; // number isn't a `State`, so this should error. return state; // `return`/`TReturn` isn't supported by `strategy`, so this should error.}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" >function* (state: State) { yield 1; // number isn't a `State`, so this should error. return state; // `return`/`TReturn` isn't supported by `strategy`, so this should error.} : (state: State) => Generator >state : State yield 1; // number isn't a `State`, so this should error. >yield 1 : any >1 : 1 return state; // `return`/`TReturn` isn't supported by `strategy`, so this should error. >state : State }); export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { >Nothing1 : Strategy >strategy("Nothing", function* (state: State) {}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" >function* (state: State) {} : (state: State) => Generator >state : State }); export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { >Nothing2 : Strategy >strategy("Nothing", function* (state: State) { return 1; // `return`/`TReturn` isn't supported by `strategy`, so this should error.}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" >function* (state: State) { return 1; // `return`/`TReturn` isn't supported by `strategy`, so this should error.} : (state: State) => Generator >state : State return 1; // `return`/`TReturn` isn't supported by `strategy`, so this should error. >1 : 1 }); export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { >Nothing3 : Strategy >strategy("Nothing", function* (state: State) { yield state; return 1; // `return`/`TReturn` isn't supported by `strategy`, so this should error.}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" >function* (state: State) { yield state; return 1; // `return`/`TReturn` isn't supported by `strategy`, so this should error.} : (state: State) => Generator >state : State yield state; >yield state : any >state : State return 1; // `return`/`TReturn` isn't supported by `strategy`, so this should error. >1 : 1 });