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

Constructor parameter decorator: "propertyKey" is undefined #20931

Closed
thomas-mindruptive opened this issue Dec 29, 2017 · 2 comments
Closed

Constructor parameter decorator: "propertyKey" is undefined #20931

thomas-mindruptive opened this issue Dec 29, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@thomas-mindruptive
Copy link

TS 2.6.2
Runtime environment: node.js 8.9.0, current Browsers

I'm trying to decorate a constructor parameter with a decorator like this:

export function inject<T>(key?: string | ClassInterface<T> | undefined) {
    ...

    return function (target: Object, propertyKey: string | symbol, paramInx: number): any {
        ...
    }
}

Expected behaviour: "propertyKey" should be defined

Actual: It is undefined

I know that this is similar to #15904. The point there is that this feature depends on the ES property declaration proposal. But I would like to reiterate that:

  • At the moment there is no way of attaining the parameter names of ctors.
  • This would make various dependcy injection scenarios much easier.
  • The transpiler is the only place to get ahold of this design time information. There are no good work-arounds.
  • Even if it is not yet defined in the ES6 proposal: Isn't that what TS is about? Bringing new, useful features to the table and eventually - as ES supports them - transpile them to ES?

Thanks a lot

@mhegazy mhegazy added the Duplicate An existing issue was already created label Jan 4, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jan 4, 2018

This is already covered in #8126 and #15904

@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants