Subscribe on changes!

TSX class: unable to use custom props on subcomponents

avatar
Dec 6th 2021

Version

3.2.23

Reproduction link

github.com

Steps to reproduce

  1. Clone repo + yarn install
  2. Open src/App.tsx
  3. View <Foo msg={'Bar'}/>
  4. Error refers to Intrinsic... not having X key

Meh Solution: Edit the IntrinsicAttributes interface to include [key: string] any to account for custom properties on class components. (runtime-dom.d.ts, line 1507)

What is expected?

At the very least, allow me to compile without raising an error. Ideally, it can infer the available props for a given class component to pair with intellisense.

What is actually happening?

TSC raises an error and blocks build


This is really a pain in the butt to solve without adjusting the types file directly. // @ts-ignore and custom edits to IntrinsicAttributes do not scale well 😭

avatar
Dec 6th 2021

Welp, I just added the custom definition to the shim.d.ts file and all is well. Closing issue since this is a fine workaround.