Is there any way to declare new typing for new props
within DefinitelyTyped
? I updated material-ui
with some new props
in SelectField
component, but typings in DefinitelyTyped
are old. Can I extend in some way SelectField
typing and add new props
types? Now I have:
<SelectField
multiple={true}
hintText="Select type"
value={[...this.state.values]}
onChange={this.onChange}
selectionRenderer={this.selectionRenderer}
>
And I need to add multiple?: boolean
and selectionRenderer: (values: any[]) => string
types. I tried to declare module 'material-ui/SelectField' {}
but it not works. Any ideas?
Ok, I found solution, @Nitzan answer it's ok, but need some improvements. When I checked out
node_modules/@types/material-ui/index.d.ts
I found thatinterface SelectFieldProps
is defined innamespace __MaterialUI
so I have to write like this:It works in
./src/typings/selectfield.d.ts
and doesn't work if I declare it in the same file where I use<SelectField />
(probably because of.d.ts
extension)You should be able to use module augmentation:
As you can see, the syntax is a bit sifferent than what you've tried.
Edit
If
SelectFieldProps
is defined in the__MaterialUI
namespace, then this should work: