mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
PR feedback
This commit is contained in:
+17
-20
@@ -983,25 +983,22 @@ module ts {
|
||||
}
|
||||
|
||||
function nextTokenCanFollowModifierForArrowFunction() {
|
||||
return nextTokenCanFollowModifier(/*isArrowFunction*/ true);
|
||||
nextToken();
|
||||
return canFollowModifierForArrowFunction();
|
||||
}
|
||||
|
||||
function nextTokenCanFollowModifier(isArrowFunction?: boolean) {
|
||||
function nextTokenCanFollowModifier() {
|
||||
nextToken();
|
||||
return canFollowModifier(isArrowFunction);
|
||||
return canFollowModifier();
|
||||
}
|
||||
|
||||
function parseAnyContextualModifier(isArrowFunction?: boolean): boolean {
|
||||
return isModifier(token) && tryParse(isArrowFunction
|
||||
? nextTokenCanFollowContextualModifierForArrowFunction
|
||||
? nextTokenCanFollowModifierForArrowFunction
|
||||
: nextTokenCanFollowContextualModifier);
|
||||
}
|
||||
|
||||
function nextTokenCanFollowContextualModifierForArrowFunction() {
|
||||
return nextTokenCanFollowContextualModifier(/*isArrowFunction*/ true);
|
||||
}
|
||||
|
||||
function nextTokenCanFollowContextualModifier(isArrowFunction?: boolean) {
|
||||
function nextTokenCanFollowContextualModifier() {
|
||||
if (token === SyntaxKind.ConstKeyword) {
|
||||
// 'const' is only a modifier if followed by 'enum'.
|
||||
return nextToken() === SyntaxKind.EnumKeyword;
|
||||
@@ -1017,24 +1014,24 @@ module ts {
|
||||
return nextTokenIsClassOrFunction();
|
||||
}
|
||||
nextToken();
|
||||
return canFollowModifier(isArrowFunction);
|
||||
return canFollowModifier();
|
||||
}
|
||||
|
||||
function canFollowModifier(isArrowFunction?: boolean): boolean {
|
||||
|
||||
function canFollowModifierForArrowFunction(): boolean {
|
||||
// Arrow functions can have an `async` modifier, but the rules for what can follow that modifier
|
||||
// differ from the rules for any other declaration.
|
||||
// The `async` modifier on an async function can only be followed by an open parenthesis,
|
||||
// or a less than token (in the case of a generic arrow function).
|
||||
// In addition, the `async` modifier must appear on the same line as the following token.
|
||||
if (isArrowFunction) {
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return token === SyntaxKind.OpenParenToken
|
||||
|| token === SyntaxKind.LessThanToken;
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return token === SyntaxKind.OpenParenToken
|
||||
|| token === SyntaxKind.LessThanToken;
|
||||
}
|
||||
|
||||
function canFollowModifier(): boolean {
|
||||
return token === SyntaxKind.OpenBracketToken
|
||||
|| token === SyntaxKind.OpenBraceToken
|
||||
|| token === SyntaxKind.AsteriskToken
|
||||
|
||||
@@ -344,11 +344,11 @@ module ts {
|
||||
// If this node was parsed as part of a decorator
|
||||
Decorator = 1 << 4,
|
||||
|
||||
// If this node was parsed in the parameters of an async function.
|
||||
AsyncParameter = 1 << 5,
|
||||
|
||||
// If this node was parsed in the 'await' context created when parsing an async function.
|
||||
Await = 1 << 6,
|
||||
Await = 1 << 5,
|
||||
|
||||
// If this node was parsed in the parameters of an async function.
|
||||
AsyncParameter = 1 << 6,
|
||||
|
||||
// If the parser encountered an error when parsing the code that created this node. Note
|
||||
// the parser only sets this directly on the node it creates right after encountering the
|
||||
@@ -356,7 +356,7 @@ module ts {
|
||||
ThisNodeHasError = 1 << 7,
|
||||
|
||||
// Context flags set directly by the parser.
|
||||
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | AsyncParameter | Await,
|
||||
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError | Await | AsyncParameter,
|
||||
|
||||
// Context flags passed as part of the modified ES6 grammar.
|
||||
YieldAndGeneratorParameterFlags = Yield | GeneratorParameter,
|
||||
|
||||
@@ -1101,7 +1101,7 @@ module ts {
|
||||
}
|
||||
|
||||
export function isAsyncFunctionLike(node: Node): boolean {
|
||||
return isFunctionLike(node) && !isAccessor(node) && (node.flags & NodeFlags.Async) === NodeFlags.Async;
|
||||
return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user