api-typings
api-typings copied to clipboard
After passing generics to Component, the methods cannot automatically infer the function types and default to Function
/**
* 页面中参与渲染的数据
*/
type ComponentData = typeof DEFAULT_DATA
/**
* 页面中的方法
*/
interface ComponentMethods extends WechatMiniprogram.Component.MethodOption {}
/**
* 页面的静态实例
*/
interface ComponentInstanceProperty {
$unbindDialog?: WechatMiniprogram.Component.TrivialInstance
}
Component<ComponentData, {}, ComponentMethods, ComponentInstanceProperty, true>
Does the official source have more recommended practices?
This problem should be difficult to solve, and the best approach might be to avoid creating types for WeChat Mini Program components and pages, instead hacking the Typescript by a typescript plugin.