diff --git a/src/apis/inject.ts b/src/apis/inject.ts index a8feaf2d..e94c7a2b 100644 --- a/src/apis/inject.ts +++ b/src/apis/inject.ts @@ -47,7 +47,12 @@ export function inject(key: InjectionKey | string): T | undefined export function inject( key: InjectionKey | string, defaultValue: T, - treatDefaultAsFactory?: boolean + treatDefaultAsFactory?: false +): T +export function inject( + key: InjectionKey | string, + defaultValue: T | (() => T), + treatDefaultAsFactory?: true ): T export function inject( key: InjectionKey | string, diff --git a/src/reactivity/ref.ts b/src/reactivity/ref.ts index a7a73a44..044a63df 100644 --- a/src/reactivity/ref.ts +++ b/src/reactivity/ref.ts @@ -113,7 +113,7 @@ export function isRef(value: any): value is Ref { return value instanceof RefImpl } -export function unref(ref: T): T extends Ref ? V : T { +export function unref(ref: T | Ref): T { return isRef(ref) ? (ref.value as any) : ref }