-
Notifications
You must be signed in to change notification settings - Fork 11
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
p({ type: Number }) doesn't work. #21
Comments
Hi, this is an intended behavior. In TypeScript, But for API like Just skip the manual annotation, most things will be fine because TS will implicit convert |
Looks like my next step should be to find how to disable that error during
compilation~
2016年11月28日 17:35,"(´・ω・`)" <[email protected]>写道:
… Hi, this is an intended behavior.
In TypeScript, Number has the type NumberConstructor, and p(Number) is a
hard coded override resolving to number.
But for API like p({type: Number}), TypeScript will resolve it using
NumberConstructor's construct signature, which resolves to Number. Note
number and Number is not compatible.
Just skip the manual annotation, most things will be fine because TS will
implicit convert number to Number and vice versa.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAjBm_E1n54Cfmn5iyHHXzZ6peptjjr-ks5rCqB2gaJpZM4K9j6v>
.
|
@whitetrefoil You can just skip manual annotation.
|
@HerringtonDarkholme This line is ok w/o annotation, but it will still be problem when I use these props somewhere else. In my current case, I'll using these props to initialize spin.js, but I'll got the same error when |
Oh... I see it. But I'm afraid this is unfixable issue. |
Yup, I guess this is the only thing we can do for now… I'm already used to fix everything using … (:3」∠) |
Just found that code like @Prop show = <boolean> p({ type: Boolean, default: false })
@Prop width = <number> p({ type: Number, default: DEFAULT_WIDTH }) works... |
It also uses type assertion. But clearly fewer key strokes! I would also recommend using @Prop show = p({ type: Boolean, default: false }) as boolean Thanks for the solution, I have collected it in FAQ! |
In case you are still interested, av-ts @0.8.1 shipped a new implementation of Now |
Nice! Will try the new version tomorrow~ |
TS v2.1.1, av-ts v0.5.4
cause
Boolean is similar.
But
p(Number)
works.The text was updated successfully, but these errors were encountered: