TypeScript Version: 3.2.0-dev.20181107
Search Terms: I was told to make an issue π€·ββοΈ
Code
This is something I encountered while working on DefinitelyTyped/DefinitelyTyped#30331; there are at least two instances of generics that are incorrectly inferred on TS@next.
It seems the compiler is overly eager to add things to the generic parameter that are not actually necessary, with incomplete types (they're just {}) and thus they end up causing errors instead. For example,
<FieldArray
name="field9"
component={ MyArrayField }
/>
is inferring FieldArray as FieldArray<{ name: {}; component: {} }> even though name and component are already present in FieldArray<{}>; this in turn causes MyArrayField to be expected to receive { name: {}; component: {} } as props, while it only receives {}.
A similar issue happened with <Button {...props}/> in the reactstrap test, see comment chain. The spread of props caused Button to basically infer its own props as being & Record<keyof props, {}>, which more obviously broke the type of children.
TypeScript Version: 3.2.0-dev.20181107
Search Terms: I was told to make an issue π€·ββοΈ
Code
This is something I encountered while working on DefinitelyTyped/DefinitelyTyped#30331; there are at least two instances of generics that are incorrectly inferred on TS@next.
It seems the compiler is overly eager to add things to the generic parameter that are not actually necessary, with incomplete types (they're just
{}) and thus they end up causing errors instead. For example,is inferring
FieldArrayasFieldArray<{ name: {}; component: {} }>even thoughnameandcomponentare already present inFieldArray<{}>; this in turn causesMyArrayFieldto be expected to receive{ name: {}; component: {} }as props, while it only receives{}.A similar issue happened with
<Button {...props}/>in the reactstrap test, see comment chain. The spread ofpropscausedButtonto basically infer its own props as being& Record<keyof props, {}>, which more obviously broke the type ofchildren.