-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Bug Report
π Search Terms
abstract, prototype, type
π Version & Regression Information
All versions I tried
β― Playground Link
Playground link with relevant code
π» Code
abstract class AnAbstract {
public abstract abstractMethod(): void;
public nonAbstractMethod(): void {
// do something
}
}
// no type error - undefined
console.log(AnAbstract.prototype.abstractMethod);
// no type error - false
console.log(AnAbstract.prototype.hasOwnProperty('abstractMethod'));
// defined
console.log(AnAbstract.prototype.nonAbstractMethod);
// true
console.log(AnAbstract.prototype.hasOwnProperty('nonAbstractMethod'));
π Actual behavior
Abstract class prototype has abstract methods in the type
π Expected behavior
Abstract class prototype to have only concrete methods in the type
I have a function that manually define methods based on what's in the prototype, unfortunately when I use an abstract class the type doesn't reflect reality.
If that type cannot change it would be great to be able to do something like:
type NoAbstract<T> = {
-abstract [key in keyof T]: T[key];
};
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript