import { Checking, type Test } from "hry-types"; import type { ReadonlyDeep } from "hry-types/src/Any/_api"; import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc"; import type { Mock_User } from "../../../RootComponent/Properties/expected/normalRequired"; import { SubComponent } from "../.."; type TestObj = { subObj: Mock_User; }; type CompDoc = ComponentDoc<{ properties: { aaa_str: string; aaa_num: number; }; }>; type RootDoc = { properties: { num: number; literal_num: 123 | 456; unionStrNum: string | number; required_obj: Mock_User | null; optional_obj?: TestObj; }; data: { str: string; literal_str: "a" | "b"; arr: string[]; }; computed: { Cuinon: string | boolean; }; }; /** * watch RootDoc中的数据字段 */ SubComponent()({ data: { aaa_str: "str", }, store: { aaa_num() { return 123; }, }, watch: { // properties 字段 num(newValue, oldValue) { Checking; Checking; }, literal_num(newValue, oldValue) { Checking<123 | 456, typeof newValue, Test.Pass>; Checking<123 | 456, typeof oldValue, Test.Pass>; }, unionStrNum(newValue, oldValue) { Checking; Checking; }, required_obj(newValue, oldValue) { Checking, typeof newValue, Test.Pass>; Checking, typeof oldValue, Test.Pass>; }, optional_obj(newValue, oldValue) { Checking, typeof newValue, Test.Pass>; Checking, typeof oldValue, Test.Pass>; }, "optional_obj.subObj"(newValue, oldValue) { Checking, typeof newValue, Test.Pass>; Checking, typeof oldValue, Test.Pass>; }, "required_obj.age"(newValue, oldValue) { Checking; Checking; }, "required_obj.id"(newValue, oldValue) { Checking; Checking; }, // data 字段 str(newValue, oldValue) { Checking; Checking; }, arr(newValue, oldValue) { Checking; Checking; }, literal_str(newValue, oldValue) { Checking<"a" | "b", typeof newValue, Test.Pass>; Checking<"a" | "b", typeof oldValue, Test.Pass>; }, // 计算字段 Cuinon(newValue, oldValue) { Checking; Checking; }, }, });