diff --git a/jest.config.ts b/jest.config.ts index 7b254c1..1564478 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -12,7 +12,7 @@ export const config = { "./src/**/*.ts", "!src/**/*.test.ts", "!src/api/navigateTo.ts", - "!src/inject.ts", + "!src/api/InstanceInject/inject.ts", "!src/thirdLib/**", ], testMatch: [ diff --git a/src/api/DefineComponent/collectOptionsForComponent.ts b/src/api/DefineComponent/collectOptionsForComponent.ts index 650e27f..4ab07d8 100644 --- a/src/api/DefineComponent/collectOptionsForComponent.ts +++ b/src/api/DefineComponent/collectOptionsForComponent.ts @@ -1,5 +1,4 @@ import type { Func } from "hry-types/src/Misc/_api"; -import { instanceConfig } from "../.."; import { BBeforeCreate } from "../../behaviors/BbeforeCreated"; import { BComputedAndWatch } from "../../behaviors/BComputedAndWatch"; import type { ComputedCache, Instance } from "../../behaviors/BComputedAndWatch/types"; @@ -8,6 +7,7 @@ import { Assign } from "../../types/Assign"; import type { WMComponent } from "../../types/OfficialTypeAlias"; import { INNERMARKER } from "../../utils/InnerMarker"; import { isEmptyObject } from "../../utils/isEmptyObject"; +import { instanceConfig } from "../InstanceInject/instanceConfig"; import type { RootComponentTrueOptions } from "../RootComponent"; import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint"; import type { diff --git a/src/inject.ts b/src/api/InstanceInject/inject.ts similarity index 95% rename from src/inject.ts rename to src/api/InstanceInject/inject.ts index bf47c45..010192b 100644 --- a/src/inject.ts +++ b/src/api/InstanceInject/inject.ts @@ -25,7 +25,7 @@ const store = { }; // 声明注入类型 js开发可以忽略 -declare module "./index" { +declare module "../.." { interface IInjectInfo { data: typeof data; store: typeof store; diff --git a/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts b/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts index f860b39..7da7b57 100644 --- a/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +++ b/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts @@ -9,6 +9,6 @@ export type LifetimesConstraint = // 官方组件生命周期 /** * 建立组件时的真正配置对象 */ - beforeCreate?: (options: FinalOptionsOfComponent) => void; + beforeCreate?: (this: void, options: FinalOptionsOfComponent) => void; } >; diff --git a/src/api/RootComponent/Lifetimes/test/normal.test.ts b/src/api/RootComponent/Lifetimes/test/normal.test.ts index 3e6f873..5a525a7 100644 --- a/src/api/RootComponent/Lifetimes/test/normal.test.ts +++ b/src/api/RootComponent/Lifetimes/test/normal.test.ts @@ -1,3 +1,4 @@ +import { Checking, Test } from "hry-types"; import { RootComponent } from "../../../.."; /** @@ -7,6 +8,8 @@ RootComponent()({ lifetimes: { // 新增声明周期可用于查看或拓展配置文件 beforeCreate(opitons) { + Checking; + opitons; }, created() { diff --git a/src/api/RootComponent/Watch/test/WtachInject.test.ts b/src/api/RootComponent/Watch/test/WtachInject.test.ts new file mode 100644 index 0000000..2a910f2 --- /dev/null +++ b/src/api/RootComponent/Watch/test/WtachInject.test.ts @@ -0,0 +1,20 @@ +import { Checking, Test } from "hry-types"; +import { RootComponent } from "../.."; + +/** + * watch data字段 深度只读 + */ +RootComponent()({ + watch: { + injectStr(newValue, oldValue) { + Checking; + + Checking; + }, + injectTheme(newValue, oldValue) { + Checking<"dark" | "light" | undefined, typeof newValue, Test.Pass>; + + Checking<"dark" | "light" | undefined, typeof oldValue, Test.Pass>; + }, + }, +}); diff --git a/src/api/RootComponent/index.ts b/src/api/RootComponent/index.ts index ca296da..ac155f5 100644 --- a/src/api/RootComponent/index.ts +++ b/src/api/RootComponent/index.ts @@ -5,6 +5,7 @@ import type { ComputeIntersection } from "hry-types/src/Object/_api"; import type { ComputeObject } from "../../types/ComputeObj"; import type { WMCompOtherOption } from "../../types/OfficialTypeAlias"; import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc"; +import { IInjectData } from "../InstanceInject/instanceConfig"; import type { ComputedConstraint } from "./Computed/ComputedConstraint"; import type { ComputedOption } from "./Computed/ComputedOption"; import type { GetComputedDoc } from "./Computed/GetComputedDoc"; @@ -61,6 +62,7 @@ type RootComponentOptions< & Required & DataDoc & StoreDoc + & IInjectData > & Partial> & ThisType< diff --git a/src/api/SubComponent/SubWatch/SubWatchOption.ts b/src/api/SubComponent/SubWatch/SubWatchOption.ts index 588f5cb..46f3314 100644 --- a/src/api/SubComponent/SubWatch/SubWatchOption.ts +++ b/src/api/SubComponent/SubWatch/SubWatchOption.ts @@ -1,4 +1,3 @@ -import type { NoInfer } from "hry-types/src/Generic/NoInfer"; import type { WatchOption } from "../../RootComponent/Watch/WatchOption"; -export type SubWatchOption = WatchOption>; +export type SubWatchOption = WatchOption; diff --git a/src/index.ts b/src/index.ts index ae4d3f9..44ae49e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,6 @@ export { type GenerateDoc, type IInjectInfo, instanceConfig, - /* istanbul ignore next */ navigateTo, type ParamsEqual, RootComponent,