Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 fix: undefined deoptimizePath when the first element is empty string #4070

Merged
merged 3 commits into from May 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ast/variables/NamespaceVariable.ts
Expand Up @@ -33,12 +33,12 @@ export default class NamespaceVariable extends Variable {
const memberVariables = this.getMemberVariables();
const memberPath = path.length <= 1 ? UNKNOWN_PATH : path.slice(1);
const key = path[0];
if (typeof key !== 'string') {
if (typeof key === 'string') {
memberVariables[key]?.deoptimizePath(memberPath);
} else {
for (const key of Object.keys(memberVariables)) {
memberVariables[key].deoptimizePath(memberPath);
}
} else {
memberVariables[key].deoptimizePath(memberPath);
}
}

Expand Down
@@ -0,0 +1,8 @@
const assert = require('assert');

module.exports = {
description: 'handles deoptimization of non-existing namespace members',
exports(exports) {
assert.strictEqual(exports.bar, undefined);
}
};
@@ -0,0 +1,4 @@
import * as ns from './other.js';

const foo = 'foo';
export const bar = ns[foo];
Empty file.