Skip to content

Commit

Permalink
fix(object): 修复 exactOptionalPropertyTypes 会影响 ConvertOptionalPart 和 …
Browse files Browse the repository at this point in the history
…ConvertOptional 结果的问题
  • Loading branch information
mengxinssfd committed Sep 12, 2023
1 parent 844dfa1 commit de1c623
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ export type TupleToObj<T extends ReadonlyArray<string | number>, V, E = null, V2
[K in T[number]]?: K extends E ? V2 : V;
};

type RequiredOptional<T> = { [K in keyof T]-?: T[K] | undefined };
// T 不转成 Required 的话会被 exactOptionalPropertyTypes 影响结果
type RequiredOptional<T, R = Required<T>> = { [K in keyof R]-?: R[K] | undefined };
/**
* 转换对象中部分可选属性为必选,并且原值类型加上`| undefined`
*
Expand Down

0 comments on commit de1c623

Please sign in to comment.