Tslint: prefer-method-signature with inline type

Created on 27 Mar 2017  路  4Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 4.5.1
  • __TypeScript version__: 2.2.1
  • __Running TSLint via__: CLI

TypeScript code being linted

export function registerGulpMultiTargetBuilds(options: {
    taskName: string,
    action: (target: string) => Promise<any>,
    config: { devTarget: string, buildTargets: string[] }
}) {
    ...
};

with tslint.json configuration:

{
    "rules": {
        "prefer-method-signature": true
    }
}

Actual behavior

"Inline typings" e.g.

options: {
    action: (target: string) => Promise<any>,
}

are currently also being linted

prefer-method-signature  Use a method signature instead of a property signature of function type.

Expected behavior

When using "inline typings" shouldn't suggest using method signature as it will cause some other lint to fail such as unused variable (parameter). Also generally when functions are passed as params are passed more as properties rather than methods (i might be wrong)

Fixed

Most helpful comment

Using action(target: string): Promise<any>; won't cause unused-parameter errors. It's just a syntax choice, nothing more.

All 4 comments

Using action(target: string): Promise<any>; won't cause unused-parameter errors. It's just a syntax choice, nothing more.

@andy-hanson I think you're assuming not because you've tried it.

this is what I'm saying

2017-03-28 20_43_39- gulp-utils ts - ssv-tools - visual studio code

(and I'm passing an argument to the function)

its also triggering member-ordering below it (but that's ok)

That's a bug in that lint rule then. TypeScript's own --noUnusedParameters doesn't warn for that.
Should be fixed by #2235, which uses TypeScript's implementation now.

Should be fixed by #2235

馃殌

Was this page helpful?
0 / 5 - 0 ratings