Абстрактный класс + смешивание + множественное наследование в Python

Хорошо, я понял это:)

Новое определение:

readonly [K in keyof T]?: RemoteOptions<T[K]>|{ fetchResource: (queryData?: any) => T[K]|T[K][any] };

Так что я заставляю TypeScript строго проверять, является ли возвращаемое значение экземпляром T[K][any], который Я считаю, что означает «тип любого члена T[K]».

И это похоже на работу. Я надеюсь, что это правильный подход, если это не так, я был бы признателен, если бы кто-то указал мне на это.

22
задан mluebke 5 May 2009 в 17:10
поделиться

1 ответ

Shouldn't the inheritance be the other way round? In the MRO foo currently comes before bar_for_foo_mixin, and then rightfully complains. With class myfoo(bar_for_foo_mixin, foo) it should work.

And I am not sure if your class design is the right way to do it. Since you use a mixin for implementing bar it might be better not to derive from foo and just register it with the 'foo' class (i.e. foo.register(myfoo)). But this is just my gut feeling.

For completeness, here is the documentation for ABCs.

19
ответ дан 29 November 2019 в 05:43
поделиться
Другие вопросы по тегам:

Похожие вопросы: