Skip to content

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

Closed
@monoclex

Description

@monoclex

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?

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Quick FixesEditor-provided fixes, often called code actions.FixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions