3 ms·
I’m a fan of the “Generic type arguments in JSX elements” - ran into a case where I needed it a few months ago. They’ve always had a workaround, but this is mor
by pininja 8y ago
I’m a fan of the “Generic type arguments in JSX elements” - ran into a case where I needed it a few months ago. They’ve always had a workaround, but this is more concise.
- btown 8y agoSo much better than the workaround here: https://github.com/Microsoft/TypeScript/issues/3960#issuecomment-301381447 https://github.com/Microsoft/TypeScript/issues/3960#issuecom... type TemplateTypedSelect = new () => Select<Template>; const TemplateTypedSelect = Select as TemplateTypedSelect; return <TemplateTypedSelect {...props} />; Our codebase was sprinkled with these, which was both silly and error-prone. This will be a huge quality-of-life improvement, and encourage people to create type-safe React components that ensure a match between their inputs and callbacks, rather than just having them put a union of all the types they can handle in both.