Skip to content

Commit 9bb68eb

Browse files
authored
fix: crash for named export with ts in es-x/no-nonstandard-*-prototype-properties rules (#255)
1 parent f12807a commit 9bb68eb

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/util/type-checker/object-type-checker-for-ts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ function buildObjectTypeCheckerForTS(context, aggressiveResult) {
6161

6262
if (declarations) {
6363
for (const declaration of declarations) {
64+
if (declaration.parent.kind === ts.SyntaxKind.SourceFile) {
65+
continue
66+
}
6467
const type = checker.getTypeAtLocation(declaration.parent)
6568
if (type && typeEquals(type, className)) {
6669
return true

tests/fixtures/test-module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export function fn() {}

tests/lib/rules/no-nonstandard-array-prototype-properties.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ new RuleTester({
127127
filename,
128128
code: "let foo = /re/.exec('re'); foo.index",
129129
},
130+
{
131+
filename,
132+
code: "import * as m from './test-module.js'; m.fn();",
133+
},
130134
],
131135
invalid: [
132136
{

0 commit comments

Comments
 (0)