Skip to content

No auto implementation refactorings for abstract class with method with explicit this parameter. #39440

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

Closed
monoclex opened this issue Jul 6, 2020 · 1 comment · Fixed by #39465
Assignees
Labels
Bug A bug in TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. Fixed A PR has been merged for this issue

Comments

@monoclex
Copy link

monoclex commented Jul 6, 2020

TypeScript Version: 4.0.0-dev.20200706

Search Terms: refactoring, abstract class, this, suggestions, intellisense,

Code

abstract class Thing {
  abstract run(): void;
}

class ThingImpl extends Thing {
}

abstract class ThingWithThis {
  abstract run(this: ThingWithThis): void;
}

class ThingWithThisImpl extends ThingWithThis {
}

Expected behavior:
Refactorings to auto implement ThingWithThisImpl as such:

abstract class Thing {
  abstract run(): void;
}

class ThingImpl extends Thing {
  run(): void {
    throw new Error("Method not implemented.");
  }
}

abstract class ThingWithThis {
  abstract run(this: ThingWithThis): void;
}

class ThingWithThisImpl extends ThingWithThis {
  run(this: ThingWithThis): void {
    throw new Error("Method not implemented.");
  }
}

Actual behavior:
Implementing the abstract class is not suggested for ThingWithThis.

image
image

Github doesn't support mp4s, so attached is a zip containing an mp4 of the problem if necessary.
problem.zip

Playground Link: [Playground Link](Playground Link)

Related Issues: N/A?

@DanielRosenwasser
Copy link
Member

Thanks to both @andrewbranch who fixed this without necessarily knowing it, and @a-tarasyuk for the test (and the other fix)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. Fixed A PR has been merged for this issue
Projects
None yet
3 participants