perf: Check for plugin only once before looping
This commit is contained in:
parent
10555c719e
commit
3a3d5cbe9c
@ -865,6 +865,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
kind: TokenType,
|
kind: TokenType,
|
||||||
): N.VariableDeclaration {
|
): N.VariableDeclaration {
|
||||||
const declarations = (node.declarations = []);
|
const declarations = (node.declarations = []);
|
||||||
|
const isTypescript = this.hasPlugin("typescript");
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
node.kind = kind.keyword;
|
node.kind = kind.keyword;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -879,7 +880,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
) {
|
) {
|
||||||
// `const` with no initializer is allowed in TypeScript.
|
// `const` with no initializer is allowed in TypeScript.
|
||||||
// It could be a declaration like `const x: number;`.
|
// It could be a declaration like `const x: number;`.
|
||||||
if (!this.hasPlugin("typescript")) {
|
if (!isTypescript) {
|
||||||
this.unexpected();
|
this.unexpected();
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user