core
core copied to clipboard
types: improve readability of built-in type
Description
We could write this in code, but the types would be unwrapped:
const date = ref(new Date())
We can declare types that should avoid reference unwrapping by writing:
declare module '@vue/reactivity' {
Export interface RefUnwrapBailTypes {
Date: Date;
}
}
But Date is a commonly used built-in type, would it be better if we support it directly?
Before
const date: Ref<{
toString: () => string;
toDateString: () => string;
toTimeString: () => string;
toLocaleString: {
(): string;
(locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): string;
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
};
... 39 more ...;
[Symbol.toPrimitive]: {
...;
};
}>
After
const date: Ref<Date>