Skip to content

Commit e120124

Browse files
perf(no-unnecessary-type-arguments): use isTypeIdenticalTo + flags checks (#723)
AI wrote this when trying to find why a rule was so slow against my company's internal codebase. Before these changes <img width="890" height="661" alt="image" src="https://github.com/user-attachments/assets/f1bfcd38-bb33-4515-8344-72e0d3fddd92" /> after <img width="885" height="645" alt="image" src="https://github.com/user-attachments/assets/e2851958-2a4a-47ad-88c5-9e2133fc3481" /> --------- Co-authored-by: Cameron <cameron.clark@hey.com>
1 parent d7837ad commit e120124

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

internal/rules/no_unnecessary_type_arguments/no_unnecessary_type_arguments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ var NoUnnecessaryTypeArgumentsRule = rule.Rule{
129129
if utils.IsIntrinsicErrorType(argType) {
130130
return
131131
}
132-
if argType != paramType && (utils.IsTypeAnyType(argType) || utils.IsTypeAnyType(paramType) || !(checker.Checker_isTypeStrictSubtypeOf(ctx.TypeChecker, argType, paramType) && checker.Checker_isTypeStrictSubtypeOf(ctx.TypeChecker, paramType, argType))) {
132+
if argType != paramType && (utils.IsTypeAnyType(argType) || utils.IsTypeAnyType(paramType) || (argType.Flags() != paramType.Flags()) || !checker.Checker_isTypeIdenticalTo(ctx.TypeChecker, argType, paramType)) {
133133
return
134134
}
135135

shim/checker/extra-shim.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"getBaseTypeOfLiteralType",
3232
"getWidenedType",
3333
"isTypeAssignableTo",
34-
"isTypeStrictSubtypeOf",
34+
"isTypeIdenticalTo",
3535
"IsDeprecatedDeclaration",
3636
"GetShorthandAssignmentValueSymbol",
3737
"getImmediateAliasedSymbol",

shim/checker/shim.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)