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
{{ message }}
Repository navigation
Error Importing ES6 Class Extending React.Component into TSX #18134
error TS2339: Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Hello> & Readonly<{ children?: ReactNode; }> & Rea...'.
error TS2607: JSX element class does not support attributes because it does not have a 'props' property.
What solutions do you suggest other than modifying the typings? Adding @augments {React.Component<any, any>} doesn't work in this case, but it looks like it worked for others.
as a workaround, you can add @augments on your JS React component to give your props a specific type, in here i have used object, but you can use { foo: string, bar: number}.
The issue seems to be with @types/react, removing it (and all packages that have it as a dependency) resolves the error, and ES6 components are imported with type any. I am still not seeing any effect by annotating the ES6 class with @augments {React.Component<any, any>}.
Activity
mhegazy commentedon Aug 30, 2017
React declaration file changed to give props and state a default of
{}. and thus they have no properties. the fix here is to change https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L274 to beobjectinstead of{}.alecmerdler commentedon Aug 30, 2017
I figured the problem was with
@types/react.What solutions do you suggest other than modifying the typings? Adding
@augments {React.Component<any, any>}doesn't work in this case, but it looks like it worked for others.mhegazy commentedon Aug 30, 2017
as a workaround, you can add
@augmentson your JS React component to give your props a specific type, in here i have usedobject, but you can use{ foo: string, bar: number}.alecmerdler commentedon Aug 30, 2017
I've updated the repo with
@augments, but I am still getting the same errors.mhegazy commentedon Aug 30, 2017
alecmerdler commentedon Aug 31, 2017
The issue seems to be with
@types/react, removing it (and all packages that have it as a dependency) resolves the error, and ES6 components are imported with typeany. I am still not seeing any effect by annotating the ES6 class with@augments {React.Component<any, any>}.