core-decorators icon indicating copy to clipboard operation
core-decorators copied to clipboard

@autobind on classes doesn't work with Typescript

Open bushmango opened this issue 8 years ago • 6 comments

SyntaxError: @autobind can only be used on functions, not: undefined

@autobind class AGreatComponent extends React.Component<{},{}> { ... }

My guess is there's a problem in the class vs function detection algorithm:

https://github.com/jayphelps/core-decorators.js/blob/master/src/autobind.js

function handle(args) { if (args.length === 1) { return autobindClass(...args); } else { return autobindMethod(...args); <-- code is going here instead } }

I'm not sure how to fix it.

I love core-decorators by the way! Made my last project much cleaner. Thanks for your work!

bushmango avatar Sep 09 '16 14:09 bushmango