-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
maybe this should call as Feature request
import util = require('util')
export class P
{
fn1(v: string)
{
return 1
}
static create()
{
console.log('P', util.inspect(this));
console.log('this.prototype.fn1', this.prototype.fn1);
// @ts-ignore
console.log('this.prototype.fn2', this.prototype.fn2);
// here has more code
return new this
}
}
export class A1 extends P
{
fn1(v: string | number)
{
return 1
}
fn2(v: string | number)
{
return 1
}
static create(): A1
{
// TS2339: Property '__proto__' does not exist on type 'typeof A1'.
let superStatic = this.__proto__;
console.dir(superStatic);
console.dir(superStatic.create);
return superStatic.create.call(this)
}
}
console.log(A1.create().fn2(1));Expected behavior:
no error, and typescript know superStatic is typeof P
Feature request here
hope can have something like
static create(): ThisType<this>make without always write
static create(): XXXor a way to get P from A1 , when we didn't know who is A1 parent class in static
Actual behavior:
TS2339: Property '__proto__' does not exist on type 'typeof A1'.
Playground Link:
Related Issues:
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript