Skip to content

Commit

Permalink
When entering a type context, 'yield' should be allowed (as long as y…
Browse files Browse the repository at this point in the history
…ou're not in strict mode).
  • Loading branch information
CyrusNajmabadi committed Nov 13, 2014
1 parent 8840c59 commit fa7d4b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/services/syntax/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit fa7d4b1

Please sign in to comment.