Я написал оболочку для соединения компонентов с магазином, добавив в магазин реквизиты. Код оболочки работает правильно и проходит тестирование.
import React, { ComponentType } from 'react';
import store from './index';
import { RootStore } from './RootStore';
interface InjectedStoreProps {
store: RootStore;
}
const withStore = (WrappedComponent: ComponentType<InjectedStoreProps>) => {
const output = ({...props}) => <WrappedComponent store={store} {...props} />;
return output;
}
export default withStore;
Однако в одном из моих тестов у меня есть
const ComponentToWrap = withStore(
({store, otherProp}) => (
<div>
<span>
{store}
</span>
<span>
{otherProp}
</span>
</div>
)
);
, что вызывает ошибку машинописи Type 'PropsWithChildren<InjectedStoreProps>' has no property 'otherProp' and no string index signature.
Я новичок в машинописи, поэтому определенно могу что-то недопонимать. Я пробовал вещи из многих поисков Google, но ни один из них не помог.
Реакция v16.8.6
Машинопись v3.4.3