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

Create the action only if the text change creation is successful. #22343

Merged
merged 2 commits into from
Mar 6, 2018

Conversation

sheetalkamat
Copy link
Member

Make change for the infer type from usage could return undefined even if type is present if the type cannot be named
Fixes #22184

@sheetalkamat sheetalkamat requested a review from a user March 5, 2018 21:28
@@ -5017,6 +5017,59 @@ namespace ts.projectSystem {
service.openExternalProject({ projectFileName: "p", rootFiles: [toExternalFile(f1.path)], options: { importHelpers: true } });
service.checkNumberOfProjects({ externalProjects: 1 });
});

it("should not crash when getting code fix from dynamic import", () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue didn't have anything to do with the server, just a bug in a codefix, so would be better as a fourslash test. See the many existing codeFixInferFromUsage... fourslash tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fourslash is not easily equipped right now to test the negative scenarios of the codeFix. The current error happens because one of the action's change is undefined and we try to map the change to code edit. I am not sure how i test that from fourslash with current infrastructure.

Copy link

@ghost ghost Mar 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a failing fourslash test in the master branch:

/// <reference path='fourslash.ts' />

// @noImplicitAny: true

// @Filename: /a.ts
////export class D {}
////export default new D();

// @Filename: /b.ts
////export class C {
////    [|set x(val) {}|]
////    method() { this.x = import("./a"); }
////}

goTo.file("/b.ts");
verify.not.codeFixAvailable();

codeFixInferFromUsageInaccessibleTypes.ts appears to be testing a similar thing, so you might add this onto that one.

Make change for the infer type from usage could return undefined even if type is present if the type cannot be named
Fixes #22184
@sheetalkamat sheetalkamat force-pushed the codeFixActionNotUndefined branch from 3049410 to 7094442 Compare March 6, 2018 19:14
@sheetalkamat sheetalkamat merged commit 36b45e3 into master Mar 6, 2018
@sheetalkamat sheetalkamat deleted the codeFixActionNotUndefined branch March 6, 2018 20:31
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants