Typescript: Property key in ParameterDecorator is always undefined

Created on 17 May 2017  路  2Comments  路  Source: microsoft/TypeScript



TypeScript Version: 2.3.2

Code

//Here is my code:
.
.
.
    constructor(
        @InputType({
            name : 'Id',
            type : 'text',
            readOnly : true,
            disabled : true,
            width : '300px',
            order : 1,
            tableColumn : 0,
            sortable : true
        })    
        public id? : number) {
    }
.
.
.

//Here is my decorator
.
.
.
export function InputType(parameters : any) {
    function actualDecorator(target: any, property: string | symbol, parameterIndex?: number): void {
        console.log(property);
.
.
.

I was hoping to get the property name, but the property is undefined.

Decorators Revisit

Most helpful comment

Sorry, but I was not convinced of that, because this is in the documentation even if it is an experimental feature of TypeScript:

https://www.typescriptlang.org/docs/handbook/decorators.html

All 2 comments

That is the intended design. There is no paramter discriptor created by the compiler. this is waiting on the finalization of the property declaration ES proposal that will define how initializes will be defined (no definition for it now in the descriptors).

Sorry, but I was not convinced of that, because this is in the documentation even if it is an experimental feature of TypeScript:

https://www.typescriptlang.org/docs/handbook/decorators.html

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blendsdk picture blendsdk  路  3Comments

Zlatkovsky picture Zlatkovsky  路  3Comments

uber5001 picture uber5001  路  3Comments

MartynasZilinskas picture MartynasZilinskas  路  3Comments

jbondc picture jbondc  路  3Comments