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

[Bug][Decorators] Type is not assignable to type 'void'. #9357

Closed
CarsonF opened this issue Jun 25, 2016 · 2 comments
Closed

[Bug][Decorators] Type is not assignable to type 'void'. #9357

CarsonF opened this issue Jun 25, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@CarsonF
Copy link

CarsonF commented Jun 25, 2016

TypeScript Version:

1.8.10

Code

function decorator<P>() {
  return (component: React.ComponentClass<P>) => {
    return component;
  }
}

class Foo extends React.Component<any, any> { }
export const WrappedFoo = decorator()(Foo); // Works

@decorator()
class Foo extends React.Component<any, any> { } // Fails

error TS1238: Unable to resolve signature of class decorator when called as an expression.
  Type 'ComponentClass<{}>' is not assignable to type 'void'.

Also specifying P gives a similar error:

@decorator<FooProps>()
class Foo extends React.Component<FooProps, any> { }

error TS1238: Unable to resolve signature of class decorator when called as an expression.
  Type 'ComponentClass<FooProps>' is not assignable to type 'void'.

I've been banging my head against this for a couple hours now. Maybe I'm missing something? It seems pretty straight forward though.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 27, 2016

I can not get this to reproduce locally with latest typescript@next and latest definition on definitely typed.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 27, 2016

Looks like #9365 and this issue are about the same problem. i would like to keep one to track this, so closing in favor of #9365

@mhegazy mhegazy closed this as completed Jun 27, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Jun 27, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

2 participants