You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically, to get Boolean (which is an instance of BooleanConstructor) to the type boolean, you just infer the new () => T function to get its instance type. This works with custom classes as well. There is also a built-in type utils InstanceType that serves the same purpose.
If you want to challenge your self further, you can try to read the real types for Vue 3 here.
Reacted by Sun, Yao Zhao, Harlen, 橙子 and gearonixx
Activity
xianshenglu commentedon Feb 26, 2021
Well, thanks for the great solution. And it takes several hours to get it.
However, based on my test, to address this
The above code solves this by
(): Tnotnew () => T. Considering the following codeSo, the original
PropConstructorworks by{ (): T }.xianshenglu commentedon Feb 26, 2021
However, another question appears
Compared with
I don't understand how does
& objectworks? Even using& 1also works. Any explanations? @antfuAlso posted in stackoverflow
xianshenglu commentedon Mar 3, 2021
Also, related issues microsoft/TypeScript#32389