mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38:41 -09:00
Fix redux connect types
This commit is contained in:
parent
dc6af45971
commit
343eef40fb
2 changed files with 10 additions and 7 deletions
|
|
@ -73,7 +73,7 @@ const Hyper = forwardRef<HTMLDivElement, HyperProps>((props, ref) => {
|
||||||
window.rpc.on('term selectAll', handleSelectAll);
|
window.rpc.on('term selectAll', handleSelectAll);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onTermsRef = (_terms: Terms) => {
|
const onTermsRef = (_terms: Terms | null) => {
|
||||||
terms.current = _terms;
|
terms.current = _terms;
|
||||||
window.focusActiveTerm = (uid?: string) => {
|
window.focusActiveTerm = (uid?: string) => {
|
||||||
if (uid) {
|
if (uid) {
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ const clearModulesCache = () => {
|
||||||
const getPluginName = (path: string) => pathModule.basename(path);
|
const getPluginName = (path: string) => pathModule.basename(path);
|
||||||
|
|
||||||
const getPluginVersion = (path: string): string | null => {
|
const getPluginVersion = (path: string): string | null => {
|
||||||
let version = null;
|
let version: string | null = null;
|
||||||
try {
|
try {
|
||||||
version = window.require(pathModule.resolve(path, 'package.json')).version as string;
|
version = window.require(pathModule.resolve(path, 'package.json')).version as string;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -460,9 +460,12 @@ export function connect<stateProps extends {}, dispatchProps>(
|
||||||
c: null | undefined,
|
c: null | undefined,
|
||||||
d: ConnectOptions = {}
|
d: ConnectOptions = {}
|
||||||
) {
|
) {
|
||||||
return (Class: ComponentType<any>, name: keyof typeof connectors) => {
|
return <P extends Record<string, unknown>>(
|
||||||
return reduxConnect<stateProps, dispatchProps, any, HyperState>(
|
Class: ComponentType<P & stateProps & dispatchProps>,
|
||||||
(state) => {
|
name: keyof typeof connectors
|
||||||
|
) => {
|
||||||
|
return reduxConnect(
|
||||||
|
(state: HyperState) => {
|
||||||
let ret = stateFn(state);
|
let ret = stateFn(state);
|
||||||
connectors[name].state.forEach((fn) => {
|
connectors[name].state.forEach((fn) => {
|
||||||
let ret_;
|
let ret_;
|
||||||
|
|
@ -488,7 +491,7 @@ export function connect<stateProps extends {}, dispatchProps>(
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
(dispatch) => {
|
(dispatch: HyperDispatch) => {
|
||||||
let ret = dispatchFn(dispatch);
|
let ret = dispatchFn(dispatch);
|
||||||
connectors[name].dispatch.forEach((fn) => {
|
connectors[name].dispatch.forEach((fn) => {
|
||||||
let ret_;
|
let ret_;
|
||||||
|
|
@ -519,7 +522,7 @@ export function connect<stateProps extends {}, dispatchProps>(
|
||||||
},
|
},
|
||||||
c,
|
c,
|
||||||
d
|
d
|
||||||
)(decorate(Class, name));
|
)(decorate(Class, name) as any) as ComponentType<P>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue