Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

etc/prefer-interface conflicts with @typescript-eslint/prefer-function-type #45

Open
Samuel-Therrien-Beslogic opened this issue May 25, 2022 · 1 comment

Comments

@Samuel-Therrien-Beslogic
Copy link

Samuel-Therrien-Beslogic commented May 25, 2022

// Interface only has a call signature, you should use a function type instead. eslint(@typescript-eslint/prefer-function-type)
interface resultFunction<TOut, TIn> { (_: TIn): TOut; }
interface ContentGetter<TRow> { (row: TRow): Content<TRow>; }
// Type can be declared using an interface. eslint (etc/prefer-interface)
type resultFunction<TOut, TIn> = (_: TIn) => TOut;
type ContentGetter<TRow> = (row: TRow) => Content<TRow>;
@Samuel-Therrien-Beslogic
Copy link
Author

Given the following

Some time after this rule was written, Anders Hejlsberg opened a PR that preserves type aliases for union and intersection types. That PR's changes should included in TypeScript 4.2, so when that version is released, the reasons for preferring interfaces might be less compelling.

and @typescript-eslint/consistent-type-definitions, I've opted to just disable this rule on my side, I don't think it's bringing much for me.

I'm leaving this issue open as I think the conflicting rules could work together, maybe with configuration. If not, feel free to close.

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

No branches or pull requests

1 participant