From f7890d4ddbde4d7fd3d2e1be0fddaaca727128f7 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 12 Nov 2014 19:07:35 -0800 Subject: [PATCH] When entering a type context, 'yield' should be allowed (as long as you're not in strict mode). --- src/services/syntax/parser.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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(); }