Skip to content

Commit c8e8475

Browse files
committed
update tsutils
1 parent 6a19dc1 commit c8e8475

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"dependencies": {
3737
"@fimbul/bifrost": "^0.6.0",
3838
"tslib": "^1.7.1",
39-
"tsutils": "^2.24.0"
39+
"tsutils": "^2.27.0"
4040
},
4141
"devDependencies": {
4242
"@fimbul/valtyr": "^0.8.0",

rules/noUnnecessaryTypeAnnotationRule.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
isTypePredicateNode,
1313
isValidNumericLiteral,
1414
isIntersectionType,
15+
getIIFE,
1516
} from 'tsutils';
1617

1718
type FunctionExpressionLike = ts.ArrowFunction | ts.FunctionExpression;
@@ -65,7 +66,7 @@ function walk(ctx: Lint.WalkContext<IOptions>, checker: ts.TypeChecker) {
6566
if (!functionHasTypeDeclarations(node))
6667
return;
6768

68-
const iife = getIife(node);
69+
const iife = getIIFE(node);
6970
if (iife !== undefined)
7071
return checkIife(node, iife);
7172

@@ -347,17 +348,6 @@ function getMinArguments(parameters: ReadonlyArray<ts.ParameterDeclaration>): nu
347348
return minArguments;
348349
}
349350

350-
function getIife(node: FunctionExpressionLike): ts.CallExpression | undefined {
351-
let prev: ts.Node = node;
352-
let parent = prev.parent!;
353-
while (parent.kind === ts.SyntaxKind.ParenthesizedExpression) {
354-
prev = parent;
355-
parent = prev.parent!;
356-
}
357-
if (parent.kind === ts.SyntaxKind.CallExpression && (<ts.CallExpression>parent).expression === prev)
358-
return <ts.CallExpression>parent;
359-
}
360-
361351
function containsTypeWithFlag(type: ts.Type, flag: ts.TypeFlags): boolean {
362352
return isUnionType(type) ? type.types.some((t) => isTypeFlagSet(t, flag)) : isTypeFlagSet(type, flag);
363353
}

0 commit comments

Comments
 (0)