Typescript Property XXX does not exist on type IntrinsicAttributes IntrinsicClassAttributes

0 votes

I'm working on a project with Typescript, React and Redux (all running in Electron), and I've run into a problem when I'm including one class based component in another and trying to pass parameters between them. Loosely speaking, I've got the following structure for the container component:

class ContainerComponent extends React.Component<any,any> {
  ..
  render() {
    const { propToPass } = this.props;
    ...
    <ChildComponent propToPass={propToPass} />
    ...
  }
}

....
export default connect(mapStateToProps, mapDispatchToProps)(ContainerComponent);

And the child component:

interface IChildComponentProps extends React.Props<any> {
  propToPass: any
}

class ChildComponent extends React.Component<IChildComponentProps, any> {
  ...
}

....
export default connect(mapStateToProps, mapDispatchToProps)(ChildComponent);

Obviously I'm only including the basics and there is much more to both of these classes but I'm still getting an error when I try and run what looks to me like valid code. The exact error that I'm getting:

TS2339: Property 'propToPass' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<{}, ComponentState>> & Readonly<{ childr...'.

When I first encountered the error I thought it was because I wasn't passing in an interface defining my props, but I created that (as you can see above) and it still doesn't work. I'm wondering, is there something I'm missing?

When I exclude the ChildComponent prop from the code in the ContainerComponent, it renders just fine (aside from my ChildComponent not having a critical prop) but with it in the JSX Typescript refuses to compile it. I think it might have something to do with the connect wrapping based on this article, but the problems in that article occurred in the index.tsx file and were a problem with the provider, and I'm getting my problems elsewhere.

Jun 7, 2022 in TypeSript by Logan
• 2,140 points
43,772 views

1 answer to this question.

0 votes

Double check the newly added object types. When object type is not exactly as expected such error is thrown.

If you need to know more about React, Its recommended to join React JS course today.

answered Jun 8, 2022 by Nina
• 3,060 points

Related Questions In TypeSript

0 votes
1 answer

Using TypeScript, and Object.assign gives me an error "property 'assign' does not exist on type 'ObjectConstructor'"

You can use type assertion, like this: (<any>Object).as ...READ MORE

answered Aug 3, 2022 in TypeSript by Abhinaya
• 1,160 points
3,291 views
0 votes
1 answer

What is "not assignable to parameter of type never" error in TypeScript?

All you have to do is define ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
48,355 views
0 votes
1 answer

TypeScript TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'

If you want a key/value data structure ...READ MORE

answered Jun 7, 2022 in TypeSript by Nina
• 3,060 points
14,172 views
0 votes
1 answer

Typescript: TS7006: Parameter 'xxx' implicitly has an 'any' type

You are using the --noImplicitAny and TypeScript doesn't know ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
19,047 views
0 votes
1 answer

SEO-friendly React-Redux app

server-side rendering is needed to do seo ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,420 points
286 views
0 votes
1 answer

SEO-friendly React-Redux app build

actually best choice is to use Nextjs ...READ MORE

answered Feb 24, 2022 in Others by narikkadan
• 63,420 points
486 views
0 votes
1 answer

How to use next-seo for setting nextjs meta tag with multiple OGP images?

https://github.com/garmeeh/next-seo use this git repo that contains ...READ MORE

answered Feb 24, 2022 in Others by narikkadan
• 63,420 points
5,063 views
0 votes
1 answer

TypeScript Object assign gives me an error property assign does not exist on type ObjectConstructor

For TypeScript 2.1 and higher, you can ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
1,502 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP