-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
observable.ref and decorate() function #1713
Comments
Does the error go away without '?'
Op ma 3 sep. 2018 21:10 schreef Давид Мзареулян <[email protected]>:
… I am trying to use MobX (5.1) with TypeScript (3.0) but without a
decorators syntax. Docs recommends to replace @-directives to decorate(Class,
{}) function. There is sample code:
import { decorate, observable } from 'mobx';
class A {
foo?: object;
}
decorate(A, {
foo: observable.ref,
});
And this code produces the following TS error in my environment:
Argument of type '{ foo: IObservableDecorator; }' is not assignable to parameter of type '{ prototype?: MethodDecorator | PropertyDecorator | MethodDecorator[] | PropertyDecorator[] | undefined; }'.
Object literal may only specify known properties, and 'foo' does not exist in type '{ prototype?: MethodDecorator | PropertyDecorator | MethodDecorator[] | PropertyDecorator[] | undefined; }'.
There is obviously something wrong with types but in fact this code works:
https://codesandbox.io/s/znyp2x33xx
What am I doing wrong and what is the recommended way to do such things?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1713>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhAKi1oh6eZ4R_itEdF6nK6zg_s-Lks5uXX63gaJpZM4WX-bx>
.
|
No, it does not. I found that the problem is related to the |
Hmm, strictFunctionTypes isn't always working… Looks like TS chooses invalid definition for 'decorate', |
This changes has been released yesterday, closing the issue |
I am trying to use MobX (5.1) with TypeScript (3.0) but without a decorators syntax. Docs recommends to replace @-directives by
decorate(Class, {})
function. There is sample code:And this code produces the following TS error in my environment:
There is obviously something wrong with types but in fact this code works: https://codesandbox.io/s/znyp2x33xx
What am I doing wrong and what is the recommended way to do such things?
The text was updated successfully, but these errors were encountered: