T.constructor should be of type T
Given ``` typescript class Example { } ``` The current type of `Example.constructor` is `Function`, but I feel that it should be `typeof Example` instead. The use case for this is as follows: I'd like to reference the current value of an overridden static property on the current class. In TypeScript v1.5-beta, doing this requires: ``` typescript class Example { static someProperty = "Hello, world!"; constructor() { // Output overloaded value of someProperty, if it is overloaded. console.log( (<typeof Example>this.constructor).someProperty ); } } class SubExample { static someProperty = "Overloaded! Hello world!"; someMethod() { console.log( (<typeof SubExample>this.constructor).someProperty ); } } ``` After this proposal, the above block could be shortened to: ``` typescript class Example { static someProperty = "Hello, world!"; constructor() { // Output overloaded value of someProperty, if it is overloaded. console.log( this.constructor.someProperty ); } } class SubExample { static someProperty = "Overloaded! Hello world!"; someMethod() { console.log( this.constructor.someProperty ); } } ``` This removes a cast to the current class.
Posted by LPGhatguy on Jul 13, 2015, 5:43 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.5,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
T.constructor should be of type T
Given ``` typescript class Example { } ``` The current type of `Example.constructor` is `Function`, but I feel that it should be `typeof Example` instead. The use case for this is as follows: I'd like to reference the current value of an overridden static property on the current class. In TypeScript v1.5-beta, doing this requires: ``` typescript class Example { static someProperty = "Hello, world!"; constructor() { // Output overloaded value of someProperty, if it is overloaded. console.log( (<typeof Example>this.constructor).someProperty ); } } class SubExample { static someProperty = "Overloaded! Hello world!"; someMethod() { console.log( (<typeof SubExample>this.constructor).someProperty ); } } ``` After this proposal, the above block could be shortened to: ``` typescript class Example { static someProperty = "Hello, world!"; constructor() { // Output overloaded value of someProperty, if it is overloaded. console.log( this.constructor.someProperty ); } } class SubExample { static someProperty = "Overloaded! Hello world!"; someMethod() { console.log( this.constructor.someProperty ); } } ``` This removes a cast to the current class.
Comments (0)
No comments yet. Start the discussion.