Skip to content

Commit

Permalink
fix: 修正自定义事件文档类型,去除readonlyDeep
Browse files Browse the repository at this point in the history
  • Loading branch information
missannil committed Feb 2, 2024
1 parent 9027e1a commit b4d329b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,13 @@ const ComponetDoc = DefineComponent({
});

Checking<typeof ComponetDoc, {}, Test.Pass>;

// 8 自定义事件文档类型与定义的类型相同
const rootComponent8 = RootComponent()({
customEvents: {
// 减少商品
decrease: Object as DetailedType<Mock_User>,
},
});

Checking<(typeof rootComponent8)["customEvents"]["decrease"], Mock_User, Test.Pass>;
4 changes: 1 addition & 3 deletions src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
import type { DetailedType } from "../../../types/DetailedType";
import type { InferDetailedType } from "../../../types/InferDetailedType";
import type {
Expand All @@ -9,8 +8,7 @@ import type {
} from "./CustomEventConstraint";
import type { AddTagForCustomEventsDoc } from "./CustomEventsTag";

export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType
? ReadonlyDeep<InferDetailedType<T>>
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ? InferDetailedType<T>
: T extends null ? null
: T extends undefined ? undefined
: T extends SimpleCustomeEventsList ? GetShortCustomEventsDoc<T[number]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Checking, type Test } from "hry-types";

import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
import type { Mock_User } from "../../Properties/test/normalRequired.test";
import type { GetShortCustomEventsDoc } from "../GetCustomEventDoc";
import { mock_shortCustomEvents } from "./normal.test";
Expand Down Expand Up @@ -31,6 +30,6 @@ Checking<ListResult, ListExpected, Test.Pass>;

type ObjResult = GetShortCustomEventsDoc<typeof mock_shortCustomEvents["obj"]>;

export type ObjExpected = ReadonlyDeep<Mock_User>;
export type ObjExpected = Mock_User;

Checking<ObjResult, ObjExpected, Test.Pass>;
3 changes: 1 addition & 2 deletions src/api/RootComponent/CustomEvents/test/normal.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Checking, type Test } from "hry-types";
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
import { type DetailedType, RootComponent } from "../../../..";
import type { Mock_User } from "../../Properties/test/normalRequired.test";
import type { CustomEventConstraint, FullCustomEvents, ShortCustomeEvents } from "../CustomEventConstraint";
Expand Down Expand Up @@ -71,7 +70,7 @@ type RootDoc = {
nothing: undefined;
unionStr: "male" | "female";
union: string | 0 | 1 | 2 | null;
obj: ReadonlyDeep<Mock_User>;
obj: Mock_User;
// 带options字段 通过联合类型加入。
bubbles: string | Bubbles;
capturePhase: null | Capture;
Expand Down

0 comments on commit b4d329b

Please sign in to comment.