This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no-inferrable-types: Add ignore-params flag
This change allows using no-inferrable types at times when you may want to still require types for method/function parameter lists (for example when using the typedef rule)
- Loading branch information
Showing
5 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// errors, inferrable type is declared | ||
let x: number = 7; | ||
~~~~~~ [number] | ||
let y: boolean = false; | ||
~~~~~~~ [boolean] | ||
let z: string = "foo"; | ||
~~~~~~ [string] | ||
|
||
// not errors, we are skipping params | ||
function foo (a: number = 5, b: boolean = true, c: string = "bah") { } | ||
|
||
class TestClass { | ||
doSomething(a: number = 5, b: boolean = true, c: string = "bah") {} | ||
} | ||
|
||
// not errors, inferrable type is not declared | ||
let _x = 7; | ||
let _y = false; | ||
let _z = "foo"; | ||
|
||
// not error, type is not inferrable | ||
let weird: any = 123; | ||
|
||
// not errors, inferrable type is not declared | ||
function bar(a = 5, b = true, c = "bah") { } | ||
|
||
// not errors, types are not inferrable | ||
function baz(a: any = 5, b: any = true, c: any = "bah") { } | ||
|
||
[number]: LHS type (number) inferred by RHS expression, remove type annotation | ||
[boolean]: LHS type (boolean) inferred by RHS expression, remove type annotation | ||
[string]: LHS type (string) inferred by RHS expression, remove type annotation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"rules": { | ||
"no-inferrable-types": [ | ||
true, | ||
"ignore-params" | ||
] | ||
} | ||
} |