mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
When entering a type context, 'yield' should be allowed (as long as you're not in strict mode).
This commit is contained in:
@@ -3778,6 +3778,23 @@ module TypeScript.Parser {
|
||||
return tryParseType() || eatIdentifierToken(DiagnosticCode.Type_expected);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user