Open charlag opened 3 years ago
Yep, this is a bug. We should not allow you to make Attrs
covariant in the definition of MComponent
, since it appears in an input position in the interface's definition.
Ah, of course, it should be contravariant, thanks!
This might be another issue but even when I declare it as contravariant (interface MComponent<-Attrs>
) it accepts things like
m(TestComponent, {})
but at least not
m(TestComponent, { another: 2 })
Issue from your last message is likely due to Flow treating {}
as an unsealed object. You can spread null to achieve an empty object without it being unsealed: { ...null }
. See #7424
Flow version: 0.156.0 (at least since 0.135.0)
Expected behavior
Making type generic does not introduce unsoundness.
Actual behavior
Context
Our Mithril definitions use types which looks similar to these: