Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): improve component compatibility with preact #24132

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Oct 29, 2021

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

#23516 (comment)

There appear to be type mismatches when using TypeScript + Preact that do not appear when using TypeScript + React. Most Ionic components do not have this issue (the auto-generated ones), but the "hand crafted" ones have this issue.

Also IonApp was being exported twice. Previously IonApp was autogenerated, but is no longer auto generated as of f3e492c.

What is the new behavior?

  • I updated these "hand crafted" components to be constructed more like the auto-generated components to avoid this mismatch.
  • Removed the redundant IonApp export

Does this introduce a breaking change?

  • Yes
  • No

Other information

@piotr-cz
Copy link

piotr-cz commented Nov 3, 2021

I'm unable to build an app. I'm not sure if it's related to this PR or problem comes from other commit.

Console output:

vite v2.6.13 building for production...
✓ 149 modules transformed.
'attachShadow' is not exported by node_modules\@stencil\core\internal\client\index.js, imported by node_modules\@ionic\core\components\ion-accordion.js
file: xxx/ionic-framework-bug-23516/node_modules/@ionic/core/components/ion-accordion.js:1:9
1: import { attachShadow, h, Host, proxyCustomElement } from '@stencil/core/internal/client';
            ^
2: import { c as config, b as getIonMode } from './ionic-global.js';
3: import { r as raf, t as transitionEndAsync, a as addEventListener, b as removeEventListener, g as getElementRoot } from './helpers.js';

Reproduction steps:

git clone https://github.com/piotr-cz/ionic-framework-bug-23516
cd ionic-framework-bug-23516
npm install
npm install @ionic/[email protected]
npm run build

@liamdebeasi
Copy link
Contributor Author

@piotr-cz Please see #24153 (comment).

@piotr-cz
Copy link

piotr-cz commented Nov 3, 2021

@liamdebeasi

Thanks, after updating to @stencil/[email protected] the issue mentioned in #23516 (comment) seems to be resolved and I can compile the source 👍

I still have to set "skipLibCheck": true, in tsconfig.json to compile, but it's expected as I'm using preact instead of react.

@liamdebeasi
Copy link
Contributor Author

What errors do you get if you don't have skipLibCheck: true?

@piotr-cz
Copy link

piotr-cz commented Nov 3, 2021

Lots of Cannot find module 'react' or its corresponding type declarations., like this one:

node_modules/@ionic/react/dist/types/components/CreateAnimation.d.ts(2,19): error TS2307: Cannot find module 'react' or its corresponding type declarations.

It's expected as preact docs suggest setting it on to compile dependencies that import react: TypeScript preact/compat configuration

@liamdebeasi
Copy link
Contributor Author

Ahh good to know. Thanks!

@piotr-cz
Copy link

piotr-cz commented Nov 3, 2021

Thank You for preparing this PR

@liamdebeasi liamdebeasi merged commit 15fc293 into next Nov 3, 2021
@liamdebeasi liamdebeasi deleted the preact-support branch November 3, 2021 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package package: react @ionic/react package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants