Fix duplicate declaration error on ambient class declarations (#14016)
This commit is contained in:
parent
2d989a983d
commit
a943f576d1
@ -706,6 +706,7 @@ export default class Scope {
|
||||
this.registerBinding(path.node.kind, declar);
|
||||
}
|
||||
} else if (path.isClassDeclaration()) {
|
||||
if (path.node.declare) return;
|
||||
this.registerBinding("let", path);
|
||||
} else if (path.isImportDeclaration()) {
|
||||
const specifiers = path.get("specifiers");
|
||||
|
||||
@ -655,6 +655,18 @@ describe("scope", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("duplicate declaration", () => {
|
||||
it("should not throw error on duplicate class and function declaration", () => {
|
||||
const ast = [
|
||||
t.classDeclaration(t.identifier("A"), t.super(), t.classBody([]), []),
|
||||
t.functionDeclaration(t.identifier("A"), [], t.blockStatement([])),
|
||||
];
|
||||
|
||||
ast[0].declare = true;
|
||||
expect(() => getPath(ast)).not.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe("global", () => {
|
||||
// node1, node2, success
|
||||
// every line will run 2 tests `node1;node2;` and `node2;node1;`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user