diff --git a/src/services/syntax/parser.ts b/src/services/syntax/parser.ts index 8dcb94e32095f..8f8bae4e5495e 100644 --- a/src/services/syntax/parser.ts +++ b/src/services/syntax/parser.ts @@ -3778,6 +3778,23 @@ module TypeScript.Parser { } function tryParseType(): ITypeSyntax { + // The rules about 'yield' only apply to actual code/expression contexts. They don't + // apply to 'type' contexts. So we disable these parameters here before moving on. + var savedYieldContext = yieldContext; + var savedGeneratorParameterContext = generatorParameterContext; + + setYieldContext(false); + setGeneratorParameterContext(false); + + var result = tryParseTypeWorker(); + + setYieldContext(savedYieldContext); + setGeneratorParameterContext(savedGeneratorParameterContext); + + return result; + } + + function tryParseTypeWorker(): ITypeSyntax { if (isFunctionType()) { return parseFunctionType(); }