Flow: interface identifier should be declared in the scope (#10220)
* fix: typo * declare name for flow interface * add test case for export overload function, typescript * test: add test Fixes #10044 * test: update test * test(flow): add multiple declarations regression test * re-enable flow test case # Conflicts: # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-declare-statements/input.js # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-interfaces-module-and-script/input.js # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-iterator/input.js * test: disable two flow dupl-decl test * fix: do not declare name for declare function until we figure out a better way * test: duplicate declare function and function would not throw
This commit is contained in:
committed by
Nicolò Ribaudo
parent
02f2d17e83
commit
fa5057f9fb
@@ -1975,7 +1975,7 @@ export default class ExpressionParser extends LValParser {
|
||||
node.params[i],
|
||||
BIND_VAR,
|
||||
allowDuplicates ? null : nameHash,
|
||||
"function paramter list",
|
||||
"function parameter list",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
type BindingTypes,
|
||||
BIND_NONE,
|
||||
BIND_LEXICAL,
|
||||
BIND_VAR,
|
||||
BIND_FUNCTION,
|
||||
SCOPE_ARROW,
|
||||
SCOPE_OTHER,
|
||||
} from "../util/scopeflags";
|
||||
@@ -270,6 +272,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.id = this.flowParseTypeAnnotatableIdentifier(
|
||||
/*allowPrimitiveOverride*/ true,
|
||||
);
|
||||
this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
|
||||
this.semicolon();
|
||||
return this.finishNode(node, "DeclareVariable");
|
||||
}
|
||||
@@ -462,6 +465,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
): void {
|
||||
node.id = this.flowParseRestrictedIdentifier(/*liberal*/ !isClass);
|
||||
|
||||
this.scope.declareName(
|
||||
node.id.name,
|
||||
isClass ? BIND_FUNCTION : BIND_LEXICAL,
|
||||
node.id.start,
|
||||
);
|
||||
|
||||
if (this.isRelational("<")) {
|
||||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user