This repository has been archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 262
@autobind on classes doesn't work with Typescript #86
Comments
What version of TypeScript? What compiler flags? |
"typescript": "^2.0.2" (RC) "compilerOptions": { |
I'm looking forward to movement on this |
I use an arrow function instead. Seems to work just fine. private handleSelection = (record, index, event) => {
this.setState(() => ({ selectedData: record }));
}; |
@0x80 Arrow function has its own set of problems.
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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!
The text was updated successfully, but these errors were encountered: