From 527c2c8bbb5c8fcfdf827dd985a09d7e7388cdad Mon Sep 17 00:00:00 2001 From: Pick Date: Fri, 17 Jul 2020 21:28:50 +0800 Subject: [PATCH] feat(types): expose DeepReadonly type (#1606) --- packages/reactivity/src/index.ts | 3 ++- packages/reactivity/src/reactive.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/reactivity/src/index.ts b/packages/reactivity/src/index.ts index bbab3118..aaf53242 100644 --- a/packages/reactivity/src/index.ts +++ b/packages/reactivity/src/index.ts @@ -22,7 +22,8 @@ export { shallowReadonly, markRaw, toRaw, - ReactiveFlags + ReactiveFlags, + DeepReadonly } from './reactive' export { computed, diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 1f01c393..38370152 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -74,7 +74,7 @@ export function shallowReactive(target: T): T { type Primitive = string | number | boolean | bigint | symbol | undefined | null type Builtin = Primitive | Function | Date | Error | RegExp -type DeepReadonly = T extends Builtin +export type DeepReadonly = T extends Builtin ? T : T extends Map ? ReadonlyMap, DeepReadonly>