Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Add configuration to no-inferrable-types to ignore annotated function parameters #1095

Closed
Arnavion opened this issue Apr 6, 2016 · 2 comments

Comments

@Arnavion
Copy link
Contributor

Arnavion commented Apr 6, 2016

The no-inferrable-types currently complains if a function parameter has both a type annotation and a default value.

TypeScript code being linted

function foo(bar: number = 0) { }

with tslint.json:

{
    "rules: {
        "no-inferrable-types": true
    }
}

Actual behavior

LHS type (number) inferred by RHS expression, remove type annotation


It would be nice if the rule had a configuration to skip function parameters. I prefer documenting the types of function parameters explicitly regardless of whether they're default-initialized or not.

@rrogowski
Copy link
Contributor

I believe this was addressed by #1190.

Running tslint on the above code example with the following rules gives no lint error.

{
  "rules": {
    "no-inferrable-types": [ true, "ignore-params" ]
  }
}

@JoshuaKGoldberg
Copy link
Contributor

Oh yes, that's correct! Whoohoo!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants