-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
When accessing static member of class you must write class name followed with dot before member name. But this is redundant when using that member inside the class itself.
Let's see an example (it's a little bit far-fetched but shows the case):
class SampleClassWithLongName {
static SCALE = 5;
private num:number;
// ...
getScaled():number {
return SampleClassWithLongName.scaleNumber(this.num);
}
static scaleNumber(n:number):number {
return n * SampleClassWithLongName.SCALE;
}
}My suggestion is to extend the functionality of static keyword (just to not introduce a new one) so it will help eliminate the need to continuously repeat class name.
With this feature our example became shorter and more readable:
class SampleClassWithLongName {
static SCALE = 5;
private num:number;
// ...
getScaled():number {
return static.scaleNumber(this.num);
}
static scaleNumber(n:number):number {
return n * static.SCALE;
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript