Skip to content

Property key in ParameterDecorator is always undefined #15904

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

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
Labels
Domain: Decorators The issue relates to the decorator syntax Revisit An issue worth coming back to

Comments

@cmargulhano
Copy link

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
Copy link
Contributor

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

@mhegazy mhegazy added Domain: Decorators The issue relates to the decorator syntax Revisit An issue worth coming back to labels May 17, 2017
@mhegazy mhegazy closed this as completed May 17, 2017
@cmargulhano
Copy link
Author

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.
Labels
Domain: Decorators The issue relates to the decorator syntax Revisit An issue worth coming back to
Projects
None yet
Development

No branches or pull requests

2 participants