page泛型写了DataOption不应该强制传CustomOption
我的用途是想限制data的类型,方法那些不强制传CustomOption泛型 可以给CustomOption设置默认值
I have the same problem. I have to define the function type in WechatMiniprogram.Page.Options's TCustom parameter which is unnecessary.

Is there any way to only define the typings of data fields and the non-function field of TCustom when using WechatMiniprogram.Page.Options?
你可以在使用泛型时继续声明一个新的接口保留你没用到的泛型。这是TS不熟的问题。
你可以在使用泛型时继续声明一个新的接口保留你没用到的泛型。这是TS不熟的问题。
Sorry, I can't understand what you mean. I would very much appreciate that if you could provide an example.
你们可以自行参考 https://github.com/miniapp-tool/mptool/tree/main/packages/enhance 。 这是一个我写的小框架用于组件打通和劫持router以提供预加载逻辑。里面有对页面、App和组件构造器的改动与二次扩展。而且保留了与原来一致的行为接口。
为什么不写个默认值呢
默认值在一些情况下可能会影响泛型推导。这边建议你俩把ts好好学学。
或者再直白一点,没人阻止你们构造一个类似这样的东西:https://github.com/miniapp-tool/mptool/blob/6d002128c9b05b33a86f4f8c6d96803f3b45ceda/packages/enhance/src/page/typings.ts#L131-L142
你直接构造一个,然后把你想要写死的泛型去掉就好了
或者再直白一点,没人阻止你们构造一个类似这样的东西:https://github.com/miniapp-tool/mptool/blob/6d002128c9b05b33a86f4f8c6d96803f3b45ceda/packages/enhance/src/page/typings.ts#L131-L142
你直接构造一个,然后把你想要写死的泛型去掉就好了
Did you mean to create a new type that provides a default type for the TCustom type parameter, like the below:
type Options<
TData extends DataOption,
TCustom extends CustomOption = any
> = (TCustom & Partial<Data<TData>> & Partial<ILifetime>) &
ThisType<Instance<TData, TCustom>>