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

Allow param decorators to use function generics #2685

Closed
ivogabe opened this issue Apr 9, 2015 · 2 comments
Closed

Allow param decorators to use function generics #2685

ivogabe opened this issue Apr 9, 2015 · 2 comments
Labels
Suggestion An idea for TypeScript

Comments

@ivogabe
Copy link
Contributor

ivogabe commented Apr 9, 2015

At the moment, parameter decorators cannot use generics of their parent function. Example:

declare function decorate<T>(): any;
class Foo {
    bar<U>(@decorate<U>() param: U) { }
}

Throws: TS2304: Cannot find name 'U'.
Suggestion: allow using function generics in parameter decorators. The example should compile.

@danquirk danquirk added the Suggestion An idea for TypeScript label Apr 9, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Apr 9, 2015

But what would that mean.. the decorator does not have access to the installation. the decorator runs only once at the class construction time, so at this point U is just any.

@ivogabe
Copy link
Contributor Author

ivogabe commented Apr 9, 2015

Well, that's a good question actually.. I was thinking about #2686, but that seems to be the only use-case of it. Closing this, since #2686 contains that already.

@ivogabe ivogabe closed this as completed Apr 9, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants