Skip to content

Commit 8071d34

Browse files
committed
update
1 parent bf9d14a commit 8071d34

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Diff for: src/script/index.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { isEnhancedParserObject, isParserObject } from "../common/parser-object"
6767
import type { TSESTree } from "@typescript-eslint/utils"
6868
import type { GenericProcessInfo } from "./generic"
6969
import { extractGeneric } from "./generic"
70+
import { isUndefined } from "lodash"
7071

7172
// [1] = aliases.
7273
// [2] = delimiter.
@@ -635,15 +636,8 @@ export function parseScriptElement(
635636
result.ast.tokens?.[0],
636637
result.ast.comments?.[0],
637638
]
638-
.sort((a, b) =>
639-
a == null
640-
? b == null
641-
? 0
642-
: 1
643-
: b == null
644-
? -1
645-
: a.range[0] - b.range[0],
646-
)
639+
.filter((e): e is NonNullable<typeof e> => Boolean(e))
640+
.sort((a, b) => a.range[0] - b.range[0])
647641
.find((t) => Boolean(t))
648642

649643
// Restore Program node location

0 commit comments

Comments
 (0)