Skip to content

fix(react): avoid type collision with @types/react@18.2.43 and greater - #28687

Merged
liamdebeasi merged 1 commit into
mainfrom
sp/react-types
Dec 12, 2023
Merged

fix(react): avoid type collision with @types/react@18.2.43 and greater#28687
liamdebeasi merged 1 commit into
mainfrom
sp/react-types

Conversation

@sean-perkins

@sean-perkins sean-perkins commented Dec 11, 2023

Copy link
Copy Markdown
Contributor

Issue number: N/A


What is the current behavior?

Ionic React projects using @types/react@18.2.43 or greater will run into a type-check error on build with IonRouterOutlet and potentially other components:

Property 'placeholder' is missing in type '{ children: Element[]; }' but required in type 'Pick<IonRouterOutlet & { basePath?: string | undefined; ref?: Ref<any> | undefined; ionPage?: boolean | undefined; } & IonicReactProps & Omit<...>, "color" | ... 254 more ... | "ionPage">'.

Definitely typed decided to make a breaking type change in a patch release: DefinitelyTyped/DefinitelyTyped@b954269

What is the new behavior?

  • Patches the type to allow for compatibility between React v16, 17 and 18.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Testing

  1. Create a new Ionic react project with the "list" template.
  2. Run npm run build
  3. Observe: Exception posted above
  4. Install the dev-build
  5. Run npm run build
  6. Observe: No exception, build passes
  7. You can additionally serve the app to verify no runtime exceptions/broken behavior.

Dev-build: 7.6.1-dev.11702322681.17e39348

@github-actions github-actions Bot added the package: react @ionic/react package label Dec 11, 2023
@puopg

puopg commented Dec 11, 2023

Copy link
Copy Markdown
Contributor

lol literally just hit this too

@sean-perkins
sean-perkins marked this pull request as ready for review December 11, 2023 21:08
@dmatora

dmatora commented Dec 12, 2023

Copy link
Copy Markdown

I'm experiencing this on "@types/react": "^18.0.17"
Fixed with npm i @types/react@17.0.71

@sean-perkins

Copy link
Copy Markdown
Contributor Author

@dmatora you should look at your lock file, not your package.json. If you install latest dependencies with ^18.0.17 it will resolve the latest minor and patch releases.

@liamdebeasi liamdebeasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on React 17 as well and did not observe any change in behavior. 👍

@liamdebeasi
liamdebeasi added this pull request to the merge queue Dec 12, 2023
Merged via the queue into main with commit 92f1b86 Dec 12, 2023
@liamdebeasi
liamdebeasi deleted the sp/react-types branch December 12, 2023 23:06
@dmatora

dmatora commented Dec 13, 2023

Copy link
Copy Markdown

@sean-perkins i created fresh project today (with npx) and it was broken out of the box

@sean-perkins

Copy link
Copy Markdown
Contributor Author

@dmatora you will need to use the posted dev-build, the nightly tag or downgrade the version of @types/react until this fix is released in the next patch release of Ionic Framework.

@chepoluis

Copy link
Copy Markdown

Hi 😃, I just add a placeholder={undefined} and it was fixed.

<IonRouterOutlet placeholder={undefined}>
......
</IonRouterOutlet>

I don't know if it is wrong, but it works for me :b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: react @ionic/react package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants