Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 08f5a74

Browse files
committed
Fix: fix issue with exporting anonymous without name
1 parent 219135b commit 08f5a74

File tree

3 files changed

+403
-9
lines changed

3 files changed

+403
-9
lines changed

analyze-scope.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class Referencer extends OriginalReferencer {
241241

242242
/**
243243
* Don't create the reference object for the key if not computed.
244-
* @param {TSEmptyBodyFunctionDeclaration} node The TSEmptyBodyFunctionDeclaration node to visit.
244+
* @param {ClassProperty} node The ClassProperty node to visit.
245245
* @returns {void}
246246
*/
247247
ClassProperty(node) {
@@ -301,14 +301,16 @@ class Referencer extends OriginalReferencer {
301301
const { id, typeParameters, params, returnType } = node;
302302

303303
// Ignore this if other overloadings have already existed.
304-
const variable = scope.set.get(id.name);
305-
const defs = variable && variable.defs;
306-
const existed = defs && defs.some(d => d.type === "FunctionName");
307-
if (!existed) {
308-
scope.__define(
309-
id,
310-
new Definition("FunctionName", id, node, null, null, null)
311-
);
304+
if (id) {
305+
const variable = scope.set.get(id.name);
306+
const defs = variable && variable.defs;
307+
const existed = defs && defs.some(d => d.type === "FunctionName");
308+
if (!existed) {
309+
scope.__define(
310+
id,
311+
new Definition("FunctionName", id, node, null, null, null)
312+
);
313+
}
312314
}
313315

314316
// Find `typeof` expressions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module "foo" {
2+
export default function (): string;
3+
}

0 commit comments

Comments
 (0)