-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
getApplicableRefactors returns "Install missing types package" quickfix #19378
Comments
I've added a workaround for this on the VS Code side but believe this should be addressed for 2.6.1. @mhegazy and @andy-ms Do you agree? |
We intentionally exposed this both as a refactor and a quick fix. If a user has |
Yes, this causes us to show the same code action twice, once from the quickfix for the error and once from the refactoring. I believe that this is a quickfix and should not be returned as a refactoring. We previously used to send compute quickFix requests to TS even if there were no errors in the currently selected code, but disabled this for performance reasons in TS 2.4. Should we look into enabling this again? |
The problem is that it is not a compile error to import from an untyped package unless the user has |
Yes that's what I'm trying to say. We currently don't even call public async provideCodeActions(
document: TextDocument,
range: Range,
context: CodeActionContext,
token: CancellationToken
): Promise<Command[]> {
const file = this.client.normalizePath(document.uri);
// This part was added when we picked up TS 2.4
const supportedActions = await this.getSupportedActionsForContext(context);
if (!supportedActions.size) {
return [];
}
const args: Proto.CodeFixRequestArgs = {
...vsRangeToTsFileRange(file, range),
errorCodes: Array.from(supportedActions)
};
const response = await this.client.execute('getCodeFixes', args, token);
return (response.body || []).map(action => this.getCommandForAction(action, file));
} We can remove the size check so that we still call |
If you ask for code fixes and there are no errors, we'll return an empty response, since there's nothing to fix. (The TS implementation of code fixes ( |
If we want to support the no implicit any case, I propose we change the getCodeFix to support empty error code requests. If that change would be too complex for 2.6, we can ship with the no implicit any case not being supported yet and look into handling it in a future release. However I feel that we need to remove this quick fix from the |
@mjbvz do you happen to have If so, i think i have a fix for this issue. |
No, my tsconfig was:
|
Longer-term solution might be #19392. |
I am unable to reproduce this locally with the setup mentioned above with 1.18-insiders and latest TS. @andy-ms , seems from your comments, you understand the issue here. can you elaborate on how i can reproduce this locally? |
I don't get the quickfix at all in insiders -- didn't think that feature was in yet? Also, @mjbvz mentioned having added a workaround. |
aah.. now i see. why do we have the quick fix associated with |
That's exactly what #19394 does. |
Sorry, was stuck trying to understand the issue and did not look at the change. |
Fixed by #19394. |
The original issue here was not addressed and the difference in semantics between quick fixes and refactorings is causing problems on our side (see microsoft/vscode#37288) I still would like install @types to be returned only as a quick fix. See my comment on the PR for more info: #19394 (comment) |
We are working on adding a new non-error diagnostic category, and moving all these refactoring to quick fix only. this should address the problem. |
TypeScript Version: 2.6.1-insiders.20171019
Code
In a empty project with a
package.json
that includeslodash
but not@types/lodash
. Try writing an import:Request quickfixs on
'lodash'
Bug
getApplicableRefactors
is also returning a quick fix here forInstall missing types package
The text was updated successfully, but these errors were encountered: