Просмотр исходного кода

feat(types): expose DeepReadonly type (#1606)

Pick 6 лет назад
Родитель
Сommit
527c2c8bbb
2 измененных файлов с 3 добавлено и 2 удалено
  1. 2 1
      packages/reactivity/src/index.ts
  2. 1 1
      packages/reactivity/src/reactive.ts

+ 2 - 1
packages/reactivity/src/index.ts

@@ -22,7 +22,8 @@ export {
   shallowReadonly,
   markRaw,
   toRaw,
-  ReactiveFlags
+  ReactiveFlags,
+  DeepReadonly
 } from './reactive'
 export {
   computed,

+ 1 - 1
packages/reactivity/src/reactive.ts

@@ -74,7 +74,7 @@ export function shallowReactive<T extends object>(target: T): T {
 
 type Primitive = string | number | boolean | bigint | symbol | undefined | null
 type Builtin = Primitive | Function | Date | Error | RegExp
-type DeepReadonly<T> = T extends Builtin
+export type DeepReadonly<T> = T extends Builtin
   ? T
   : T extends Map<infer K, infer V>
     ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>