-
-
Notifications
You must be signed in to change notification settings - Fork 376
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃搸 Implement nursery/useUnifiedTypeSignature
- typescript-eslint/unified-signatures
#50
Comments
lint/useUnifiedSIgnature
- typescript-eslint/unified-signatures
lint/useUnifiedSgnature
- typescript-eslint/unified-signatures
lint/useUnifiedSgnature
- typescript-eslint/unified-signatures
lint/useUnifiedSignature
- typescript-eslint/unified-signatures
I suggest |
lint/useUnifiedSignature
- typescript-eslint/unified-signatures
lint/useUnifiedTypeSignature
- typescript-eslint/unified-signatures
Ping for @unvalley . Are you still interested? |
@ematipico Sorry for holding If anyone is interested, please work on it. |
I'd like to work on this.
I would suggest |
All yours :)
|
@n-gude are you still interested in this issue? |
Yes, I'm working on this. It's just more complex than I initially thought and I was very busy the last few weeks. But I'm nearly done. @Conaclos Sorry, I completely forgot to respond. -function foo(a: number, b: number): void;
-function foo(a: number, b: string): void;
+function foo(a: number, b: number | string); but also catches cases like this: -function bar(a: number, b: number, c?: number, d?: number): void;
-function bar(a: number, b?: number): void;
+function bar(a: number, b?: number, c?: number, d?: number): void; Therefore I would prefer Furthermore, I need your opinion on the following:
I haven't added the |
I don't think we have much choice because a function implementation has to be immediately following the declaration. Another thing to consider is how to deal with JSDoc/TSDoc or plain comments preceding those function signatures. It looks like we have too many things to consider if we are to provide a fix action, maybe we shouldn't? |
Ah, yes. For normal function declarations and class methods, you are right, but interface methods could have others in between. interface I {
a(x: number): void;
b(): void;
a(x: string): void;
}
Yeah, good question. Maybe combine/append them as well? I would make the code fix unsafe anaway because its a complex rule and you should review it.
That would be sad... That's what annoyed me about the original rule. The diagnostic is so vague sometimes that you don't know how it should be 'fixed'. How would you express the changes for this example in a diagnostic?: -function bar(a: number, b: number, c?: number, d?: number): void;
-function bar(a: number, b?: number): void;
+function bar(a: number, b?: number, c?: number, d?: number): void; |
Personally I prefer
Yes. However, a parameter name could be cited in the documentation of the signature. - function f(foo: number, bar: number): void;
- function f(foo: number, baz: string): void;
+ function foo(a: number, barBaz: number | string);
+1
I could replace the last one (or the first one). If we are going to provide an unsafe fix, then I think we can just concatenate the parameter names (when they are different), and appends comments. - /** A */
- function f(foo: number, bar: number): void;
- /** B */
- function f(foo: number, baz: string): void;
+ /** A */
+ /** B */
+ function foo(a: number, barBaz: number | string); |
lint/useUnifiedTypeSignature
- typescript-eslint/unified-signatures
nursery/useUnifiedTypeSignature
- typescript-eslint/unified-signatures
I agree what you said above. I just want to add one more thing: for JSDoc/TSDoc comments, they may have parameters and types to describe the function signature, so renaming and retyping the parameters can invalidate these docs. It should be warned in the doc page of this rule. |
Description
unified-signatures
Want to contribute? Lets you know you are interested! We will assign you to the issue to prevent several people to work on the same issue. Don't worry, we can unassign you later if you are no longer interested in the issue! Read our contributing guide and analyzer contributing guide.
The text was updated successfully, but these errors were encountered: