Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(types): update inject and unref type (#888)
  • Loading branch information
MinatoHikari committed Jan 16, 2022
1 parent 796ffef commit 315f6ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/apis/inject.ts
Expand Up @@ -47,7 +47,12 @@ export function inject<T>(key: InjectionKey<T> | string): T | undefined
export function inject<T>(
key: InjectionKey<T> | string,
defaultValue: T,
treatDefaultAsFactory?: boolean
treatDefaultAsFactory?: false
): T
export function inject<T>(
key: InjectionKey<T> | string,
defaultValue: T | (() => T),
treatDefaultAsFactory?: true
): T
export function inject(
key: InjectionKey<any> | string,
Expand Down
2 changes: 1 addition & 1 deletion src/reactivity/ref.ts
Expand Up @@ -113,7 +113,7 @@ export function isRef<T>(value: any): value is Ref<T> {
return value instanceof RefImpl
}

export function unref<T>(ref: T): T extends Ref<infer V> ? V : T {
export function unref<T>(ref: T | Ref<T>): T {
return isRef(ref) ? (ref.value as any) : ref
}

Expand Down

0 comments on commit 315f6ab

Please sign in to comment.