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

prefer-method-signature with inline type #2414

Closed
stephenlautier opened this issue Mar 27, 2017 · 4 comments
Closed

prefer-method-signature with inline type #2414

stephenlautier opened this issue Mar 27, 2017 · 4 comments

Comments

@stephenlautier
Copy link

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)

@andy-hanson
Copy link
Contributor

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

@stephenlautier
Copy link
Author

stephenlautier commented Mar 28, 2017

@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)

@andy-hanson
Copy link
Contributor

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.

@JoshuaKGoldberg
Copy link
Contributor

Should be fixed by #2235

🚀

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