You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This codefix sounds good. It replaces something that is tedious to do by hand. C# has this codefix. It would even be nice to have a codefix that deletes parameters when you pass too few.
How does it handle overloads? Does it add to the longest matching one? (C# seems to do this)
Does it break other callers? (C# does)
Should the new parameter be optional? (C# gives codefixes for both; one is a new overload which is equivalent to optional)
Is the new parameter always added to the end? Can the new parameter be added in the middle based on which types match?
Does it offer the codefix for 'external' code -- basically, code from node_modules. (No idea how other codefixes handle this.)
There is a codefix to remove unused parameters from a function declaration. Since it's from the declaration side it shouldn't interfere. But it may edit callers to remove the parameters (Need to test this -- unused parameters should never have callers in order to be 'unused', right?)
This codefix sounds good. It replaces something that is tedious to do by hand. C# has this codefix. It would even be nice to have a codefix that deletes parameters when you pass too few.
Are you suggesting implementing a Quick Fix to address this case? I think fixUnusedIdentifier could be expanded to cover this new trigger case.
functionf(a: number){}f();// QF to remove a
How does it handle overloads? Does it add to the longest matching one? (C# seems to do this)
Yes, the Quick Fix attempts to utilize the longest overload declaration.
Does it break other callers? (C# does)
Yes, I think we can attempt to use findAllRefs and update other callers. Not sure if it's safe to do, though...
Should the new parameter be optional? (C# gives codefixes for both; one is a new overload which is equivalent to optional)
It's a topic open for discussion. The safest route is to use optional parameters (it depends on the arg position), however, I think if a user calls the function with a new argument, there's an expectation that they want this parameter to be explicitly declared in the signature.
Is the new parameter always added to the end? Can the new parameter be added in the middle based on which types match?
Yes.
Does it offer the codefix for 'external' code -- basically, code from node_modules. (No idea how other codefixes handle this.)
Need to check, I think there's a utility to handle that.
There is a codefix to remove unused parameters from a function declaration. Since it's from the declaration side it shouldn't interfere. But it may edit callers to remove the parameters (Need to test this -- unused parameters should never have callers in order to be 'unused', right?)
unused is marked as unused whether or not f(1, 2, 3) is in the file. However, I just tested the quick fix, and it's smart enough not to offer to remove unused when f(1, 2, 3) is present. Only the "prefix unused with _" quick fix is offered. When f(1, 2, 3) is not in the file, a second quick fix to remove unused is offered.
In summary, there's nothing to do here; the existing quick fix is smart enough already.
Most of the other questions from the design meeting don't require changing anything, as far as I can see. The only 2 open ones are
whether to offer two code fixes (optional/non-optional) -- I slightly prefer two since I think people will sometimes want non-optional to force themselves to update all callers.
how to avoid offering the quick fix when the callee comes from node_modules.
whether to offer two code fixes (optional/non-optional) -- I slightly prefer two since I think people will sometimes want non-optional to force themselves to update all callers.
Should it be provided for both overload+signature declarations and signature declarations?
I don't think we need to distinguish between adding a parameter to overload signatures vs implementation signatures: to work correctly, you have to add the new parameter to the implementation signature and at least one overload signature.
I like the wording "Add missing parameter" vs "Add optional parameter".
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #51870