-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Milestone
Description
TypeScript Version: 2.0.2
Code
I'm taking advantage of shorthand property declarations syntax via constructor.
The code below contains a problem, it won't work as expected for class City
, it such case typescript will treat PropertyDecorator
as ParameterDecorator
, there is no way to supply both PropertyDecorator
and ParameterDecorator
simultaneously for such shorthand syntax:
function PropertyDecorator(target: Object, propertyKey: string | symbol) { }
function ParameterDecorator(target: Object, propertyKey: string | symbol, index: number) {}
class Country {
@PropertyDecorator public name: string;
public constructor(name: string) {
this.name = name;
}
}
class City {
public constructor(
@PropertyDecorator public name: string,
@PropertyDecorator public country: Country) {
}
}
It looks better to use the following syntax that would allow distinguishing different decorator types:
function PropertyDecorator(target: Object, propertyKey: string | symbol) { }
function ParameterDecorator(target: Object, propertyKey: string | symbol, index: number) {}
class Country {
public name: string;
public constructor(name: string) {
this.name = name;
}
}
class City {
public constructor(
@PropertyDecorator public @ParameterDecorator name: string,
@PropertyDecorator public @ParameterDecorator country: Country) {
}
}
ackava, lsagetlethias, doivosevic, bajtos, cherryblossom000 and 11 more
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