-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 无注入数据时 watch监控类型错误的问题和SubComponentdata数据为字面量类型造成实例类型错误的问题
- Loading branch information
Showing
6 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { IfExtends } from "hry-types/src/Any/IfExtends"; | ||
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection"; | ||
|
||
type _AssignValues<Target, Source, UniqueKey extends keyof Target> = ComputeIntersection< | ||
& { [k in UniqueKey]: Target[k] } | ||
// @ts-ignore | ||
& { [k in Exclude<keyof Target, UniqueKey>]: Source[k] } | ||
>; | ||
|
||
/** | ||
* Target与Source相同的key类型变为Source的类型 | ||
* @example | ||
* ```ts | ||
* type obj = { a: "a"; b: "b"; c: boolean }; | ||
* type obj2 = { a: number; b: string; d: number }; | ||
* type test = AssignValues<obj, obj2>; | ||
* // test = { a: number; b: string; c: boolean} | ||
* type test1 = AssignValues<unknown, obj2>; // unknown | ||
* ``` | ||
*/ | ||
export type AssignValues<Target, Source> = IfExtends< | ||
unknown, | ||
Target, | ||
unknown, | ||
_AssignValues<Target, Source, Exclude<keyof Target, keyof Source>> | ||
>; |