Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property key in ParameterDecorator is always undefined #15904

Closed
cmargulhano opened this issue May 17, 2017 · 2 comments
Closed

Property key in ParameterDecorator is always undefined #15904

cmargulhano opened this issue May 17, 2017 · 2 comments

Comments

@cmargulhano
Copy link

@cmargulhano cmargulhano commented May 17, 2017

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.

@cmargulhano cmargulhano changed the title Property key in ParameterDecorator always is null Property key in ParameterDecorator always is undefined May 17, 2017
@cmargulhano cmargulhano changed the title Property key in ParameterDecorator always is undefined Property key in ParameterDecorator is always undefined May 17, 2017
@mhegazy

This comment has been minimized.

Copy link

@mhegazy mhegazy commented May 17, 2017

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).

@cmargulhano

This comment has been minimized.

Copy link
Author

@cmargulhano cmargulhano commented May 17, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.