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 9e273dd commit f7890d4
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

1 comment on commit f7890d4

@JsonFreeman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have to do this in more places once we introduce classes inside functions, and stuff like that.

Please sign in to comment.