-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
Getters, mixins, classes
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ
β― Playground Link
π» Code
function mixin<T extends {new (...args: any[]): {}}> (superclass: T) {
return class extends superclass {
get validationTarget (): HTMLElement {
return document.createElement("input")
}
}
}
class BaseClass {
get validationTarget (): HTMLElement {
return document.createElement("div")
}
}
class MyClass extends mixin(BaseClass) {
get validationTarget (): HTMLElement {
return document.createElement("select")
}
}
Output
"use strict";
function mixin(superclass) {
return class extends superclass {
get validationTarget() {
return document.createElement("input");
}
};
}
class BaseClass {
get validationTarget() {
return document.createElement("div");
}
}
class MyClass extends mixin(BaseClass) {
get validationTarget() {
return document.createElement("select");
}
}
Compiler Options
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"target": "ES2017",
"jsx": "react",
"module": "ESNext",
"moduleResolution": "node"
}
}
Playground Link: Provided
π Actual behavior
The mixin creates a property accessor instead of a getter
π Expected behavior
The mixin should create a getter and not a property accessor
Additional information about the issue
Seems related:
Duplicate of: #44938
DRiFTy17
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases