Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Dec 16, 2022
1 parent 5667519 commit a1da151
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ast/variables/ExportDefaultVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ export default class ExportDefaultVariable extends LocalVariable {
}

forbidName(name: string) {
super.forbidName(name);
const original = this.getOriginalVariable();
if (original !== this) {
if (original === this) {
super.forbidName(name);
} else {
original.forbidName(name);
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/function/samples/class-name-conflict-4/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
description: 'does not shadow variables when preserving class names'
};
5 changes: 5 additions & 0 deletions test/function/samples/class-name-conflict-4/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var Foo = class {};

export default Foo;

Foo = 'reassigned';
14 changes: 14 additions & 0 deletions test/function/samples/class-name-conflict-4/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Bar from './reexport';

const wrapper = () => {
class Foo extends Bar {
static assertName() {
assert.strictEqual(this.name, 'Foo');
assert.strictEqual(super.name, 'Foo');
}
}

return Foo;
};

wrapper().assertName();
2 changes: 2 additions & 0 deletions test/function/samples/class-name-conflict-4/reexport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Foo from './foo';
export default Foo;

0 comments on commit a1da151

Please sign in to comment.