tslint: i want to force param typedef but allow inferred types

Viewed 358

In my tslint.json I have this:

"typedef": [true, "call-signature", "parameter"],
"no-inferrable-types": [true, "ignore-params"],

as I want to force functions to have a return type and params to have a type however this forces me to have type on inferred params. example:

This fails even though start and end are inferred as numbers:

transform(start = 6, end = 4): number {
    return;
}

Is there a way to force the params to have a type ONLY when they are not initialised like the example?

This should pass:

transform(start = 6, end = 4): number {
    return;
}

This should fail:

transform(start, end): number {
    return;
}
1 Answers

I know it's an old one.

Should you just remove typedef and enable no-inferrable-types without any parameters?

For the function return values, you can use @typescript-eslint/explicit-module-boundary-types

Related