Skip to content

Commit f46061a

Browse files
committed
no-unnecessary-type-annotation: detect other IIFE style
Fixes: #56
1 parent c1ceca0 commit f46061a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rules/noUnnecessaryTypeAnnotationRule.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,11 @@ function getMinArguments(parameters: ReadonlyArray<ts.ParameterDeclaration>): nu
347347
}
348348

349349
function getIife(node: FunctionExpressionLike): ts.CallExpression | undefined {
350-
if (node.parent!.kind !== ts.SyntaxKind.ParenthesizedExpression)
351-
return;
352-
let prev = node.parent!;
350+
let prev: ts.Node = node;
353351
let parent = prev.parent!;
354352
while (parent.kind === ts.SyntaxKind.ParenthesizedExpression) {
355353
prev = parent;
356-
parent = parent.parent!;
354+
parent = prev.parent!;
357355
}
358356
if (parent.kind === ts.SyntaxKind.CallExpression && (<ts.CallExpression>parent).expression === prev)
359357
return <ts.CallExpression>parent;

test/rules/no-unnecessary-type-annotation/default/test.ts.lint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ take<((a: string) => string) | ((a: string) => number)>((a: string): string => a
5757
(function(foo: "foo") {})("foo");
5858
(function(foo: string) {})("foo");
5959
~~~~~~~~ [fail]
60+
(function(foo: string) {}("foo"));
61+
~~~~~~~~ [fail]
6062
(function(foo): void {})("foo");
6163
(function(foo?): void {})("foo");
6264
(function(param: string, ...foo: string[]) {})("foo", "bar", "baz");

0 commit comments

Comments
 (0)