@igoryusha22

Как правильно избежать ошибки ...'T' could be instantiated with a different subtype of constraint 'Person'...?

https://codesandbox.io/s/epic-sanne-6zxe13?file=/s...

Задача, нужен HOC который вернет новый компонент, который перестанет принимать какие-то пропсы, и модифицирует какой-то колбек.

Но ловлю ошибку.
Type 'Omit<PropsWithChildren<Omit<T, "personName">>, "onPersonAgeUpdate"> & { personName: string; onPersonAgeUpdate: (newAge: number) => void; }' is not assignable to type 'IntrinsicAttributes & T & { children?: ReactNode; }'.
  Type 'Omit<PropsWithChildren<Omit<T, "personName">>, "onPersonAgeUpdate"> & { personName: string; onPersonAgeUpdate: (newAge: number) => void; }' is not assignable to type 'T'.
    'Omit<PropsWithChildren<Omit<T, "personName">>, "onPersonAgeUpdate"> & { personName: string; onPersonAgeUpdate: (newAge: number) => void; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Person'.ts(2322)


Почему он считает, что они не совместимы?
  • Вопрос задан
  • 82 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы