You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import*asReactfrom"react";exportinterfaceFooOptions{x: string;y?: string;[key: string]: any;// remove this and everything is ok}interfaceFooPropsextendsFooOptions{a: boolean;}classFooextendsReact.Component<FooProps>{publicstaticdefaultProps={a: true,};publicrender(){return<div>RemoveindexsignaturefromFooOptionstomakethiswork</div>}}classAppextendsReact.Component{publicrender(){return(<Foox={""}/>);}}
Expected behavior:
Default property recognized as present
Actual behavior:
Error that parameter a is missing: Property 'a' is missing in type '{ x: string; }' but required in type 'Readonly<FooProps>'
Interestingly, as I recently mentioned elsewhere, we don't actually implement any of the logic for checking defaultProps in the compiler - that's entirely in the domain of the react.d.ts over on DefinitelyTyped. I'd re-file this over there, where one of the .d.ts file maintainers can take a look at it.
TypeScript Version:
Search Terms:
defaultprops index signature
Code
Expected behavior:
Default property recognized as present
Actual behavior:
Error that parameter
a
is missing:Property 'a' is missing in type '{ x: string; }' but required in type 'Readonly<FooProps>'
Playground Link:
Related Issues:
#23812
The text was updated successfully, but these errors were encountered: