-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
fix(types): fix shallowRef
type error
#9839
Conversation
Size ReportBundles
Usages
|
CodSpeed Performance ReportMerging #9839 will degrade performances by 42.4%Comparing Summary
Benchmarks breakdown
|
@@ -201,11 +201,23 @@ if (refStatus.value === 'initial') { | |||
expectType<IsAny<typeof a>>(false) | |||
} | |||
|
|||
describe('shallowRef with generic', <T>() => { | |||
const r = ref({}) as MaybeRef<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does break the MaybeRef<T>
case, but the correctness improvement is worth the tradeoff IMO.
In #7853, a function overload
export function shallowRef<T>(value: MaybeRef<T>): Ref<T> | ShallowRef<T>
was added. Due toMaybeRef<T>
encompassing all types, this resulted in all instances ofshallowRef
being inferred asRef<T> | ShallowRef<T>
, instead of justShallowRef<T>
.In this PR, I have modified the function overload, resulting in the following types: