diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts new file mode 100644 index 00000000000..2f30fe9d902 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { + return state; +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { + yield state; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield ; + return state; +}); + \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts new file mode 100644 index 00000000000..58411e409b8 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts @@ -0,0 +1,43 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + yield 1; + return state; +}); + +export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { +}); + +export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + return 1; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield state; + return 1; +}); \ No newline at end of file