Skip to content

Commit

Permalink
prevent a crash when ClassType.name is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Sep 30, 2024
1 parent 356b8f6 commit 9cec80a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,4 +1256,10 @@ describe('util', () => {
);
});
});

describe('isClassUsedAsFunction', () => {
it('does not crash when class type has no name', () => {
util.isClassUsedAsFunction(new ClassType(undefined), undefined, { flags: SymbolTypeFlag.runtime });
});
});
});
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2378,8 +2378,8 @@ export class Util {
if ((options?.flags ?? 0) & SymbolTypeFlag.runtime &&
isClassType(potentialClassType) &&
!options.isExistenceTest &&
potentialClassType.name.toLowerCase() === this.getAllDottedGetPartsAsString(expression).toLowerCase() &&
!expression.findAncestor(isNewExpression)) {
potentialClassType.name?.toLowerCase() === this.getAllDottedGetPartsAsString(expression)?.toLowerCase() &&
!expression?.findAncestor(isNewExpression)) {
return true;
}
return false;
Expand Down

0 comments on commit 9cec80a

Please sign in to comment.