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(core.d.ts): export HTMLAttributes and DevJSX to fix TS4023 issue … #5141

Merged
merged 3 commits into from
Sep 15, 2023

Conversation

gparlakov
Copy link
Contributor

fix #5140

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests / types / typos

Description

When creating a UI library for Qwik and strong typing the properties using QwikIntrinsicElement used like

export type MyLabelProp = QwikIntrinsicElement['label']

that results in a TS4023 issue.

Reproduction
https://github.com/gparlakov/qwik-lib-TS4023-issue-repro

Suggest exporting all from the jsx-generated.ts file instead of just the few types currently exported.

Previously libraries have done that like ngrx/platform#1118 or guessing what was done to fix #2783

TS issue microsoft/TypeScript#5711

Here's the real world use case from qwik-ui

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

@netlify
Copy link

netlify bot commented Sep 10, 2023

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit da8fb64

@zanettin zanettin added WAITING FOR: team Waiting for one of the core team members to review and reply COMP: typing labels Sep 10, 2023
@mhevery
Copy link
Contributor

mhevery commented Sep 11, 2023

Thanks for the fix! Could you help me better understand this. Why is this not sufficient?

import { jsxDEV, QwikIntrinsicElements } from "@builder.io/qwik/jsx-runtime";

@gparlakov
Copy link
Contributor Author

Hey @mhevery, sure!

So why?:

  • It seems QwikIntrinsicElements is not exported from the mentioned file
    image
  • also jsxDev is a function definition while DevJSX is a interface (with fileName etc)
  • also we really need the LabelHTMLAttributes (the constituents of QwikIntrinsicElements) b/c that is what needs to be named in the d.ts file
  • and finally - let's say that these were indeed exported from jsx-runtime - then how does a developer decide if they should import QwikIntrinsicElements from core (i.e.@builder.io/qwik) or @builder.io/qwik/jsx-runtime ?

@shairez
Copy link
Contributor

shairez commented Sep 12, 2023

Thanks @gparlakov !

There's a build error
Can you please run pnpm api.update and commit the changes?

Update api.md with the exposed DevJSX and QwikIntrinsicElements constituents

re QwikDev#5140
@gparlakov
Copy link
Contributor Author

Done.

I was wondering if we can have a kind of e2e test that makes sure this thing does not regress. Kind of like - get the minimal repro component and make sure it can compile the d.ts files. Any ideas?

The straightforward way would be

  • a (new?) folder with d.ts focused tests
  • the component that uses these fixed types
  • a script that runs tsc -b aiming at d.ts only files

How does that sound?

@gparlakov
Copy link
Contributor Author

Oh, I think I need to annotate the exported types to make the api.update run successfully.

On it.

@mhevery
Copy link
Contributor

mhevery commented Sep 13, 2023

Is this ready to merge?

@gparlakov
Copy link
Contributor Author

gparlakov commented Sep 14, 2023 via email

@shairez
Copy link
Contributor

shairez commented Sep 14, 2023

Thanks @gparlakov !

About e2e, there's a whole pacakge of e2e apps that we could add a component which uses one of the types.
We can do it on a separate PR

I'm merging so we could issue a version that fixes this asap

Thanks again!

@gparlakov
Copy link
Contributor Author

gparlakov commented Sep 14, 2023 via email

@shairez
Copy link
Contributor

shairez commented Sep 14, 2023

Rethinking about it @gparlakov

I see it adds TONS of stuff to the documentation
Do you think we need ALL of this? or we can constrain it to specific common types most devs will need?

@gparlakov
Copy link
Contributor Author

gparlakov commented Sep 14, 2023 via email

@gparlakov
Copy link
Contributor Author

gparlakov commented Sep 14, 2023

@shairez I can think of one way to test it for yourself (+ double check my logic)

  • open a component that relies on QwikIntrinsicElement['div'] (or label, li whatever)
  • go to the definition
  • that should take you to IntrinsicHTMLElements
  • notice almost every one of these has a dedicated Attributes type(AnchorHTMLAttributes, AreaHTMLAttributes, ...)
  • each of these is what I'm trying to expose (and update documentation to show it's public - example)

@mhevery
Copy link
Contributor

mhevery commented Sep 15, 2023

Thought about it some more, and convinced me that this is what is already being exported, just in a weird way, so it is public....

@mhevery mhevery merged commit 1f0aa04 into QwikDev:main Sep 15, 2023
20 checks passed
@shairez shairez removed the WAITING FOR: team Waiting for one of the core team members to review and reply label Sep 18, 2023
@gparlakov gparlakov deleted the fix-5140-typescript-error-TS4023 branch September 20, 2023 16:32
kodiakhq bot pushed a commit to ascorbic/unpic-img that referenced this pull request Sep 24, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@builder.io/qwik](https://qwik.builder.io/) ([source](https://togithub.com/BuilderIO/qwik)) | [`1.2.11` -> `1.2.12`](https://renovatebot.com/diffs/npm/@builder.io%2fqwik/1.2.11/1.2.12) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@builder.io%2fqwik/1.2.12?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@builder.io%2fqwik/1.2.12?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@builder.io%2fqwik/1.2.11/1.2.12?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@builder.io%2fqwik/1.2.11/1.2.12?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>BuilderIO/qwik (@&#8203;builder.io/qwik)</summary>

### [`v1.2.12`](https://togithub.com/BuilderIO/qwik/releases/tag/v1.2.12)

[Compare Source](https://togithub.com/BuilderIO/qwik/compare/v1.2.11...v1.2.12)

##### What's Changed

-   docs: interactive resumability Demo component to place on homepage by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#4990
-   Insights by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5146
-   docs: add routeAction$ caveat by [@&#8203;gioboa](https://togithub.com/gioboa) in [QwikDev/qwik#5147
-   fix(insight): Limit the size of data retrieved from the database by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5149
-   fix(insight): Limit the size of data retrieved from the database by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5151
-   chore(github-action): added semantic pr title check by [@&#8203;zanettin](https://togithub.com/zanettin) in [QwikDev/qwik#5152
-   fix(github-action): do not validate draft PRs by [@&#8203;zanettin](https://togithub.com/zanettin) in [QwikDev/qwik#5153
-   fix(github-action): do not validate draft PRs - revert by [@&#8203;zanettin](https://togithub.com/zanettin) in [QwikDev/qwik#5155
-   docs: Add expobeds.com to the showcase by [@&#8203;ilianiv](https://togithub.com/ilianiv) in [QwikDev/qwik#5159
-   chore: Update 🐼 PandaCSS integration dev dependency by [@&#8203;mrhoodz](https://togithub.com/mrhoodz) in [QwikDev/qwik#5156
-   feat: leaflet map integration adapter by [@&#8203;anartzdev](https://togithub.com/anartzdev) in [QwikDev/qwik#5158
-   fix: Ignore blob URL on getting image info by [@&#8203;genki](https://togithub.com/genki) in [QwikDev/qwik#5150
-   docs(qwik-city): correct the links to endpoints page by [@&#8203;wtlin1228](https://togithub.com/wtlin1228) in [QwikDev/qwik#5167
-   docs(qwik-city): add validators by [@&#8203;wtlin1228](https://togithub.com/wtlin1228) in [QwikDev/qwik#5166
-   fix: Bun install by [@&#8203;EamonHeffernan](https://togithub.com/EamonHeffernan) in [QwikDev/qwik#5165
-   docs(qwik): Fixed Link by [@&#8203;pipisso](https://togithub.com/pipisso) in [QwikDev/qwik#5169
-   fix(qwik-city): Fix rewrite home route by [@&#8203;claudioshiver](https://togithub.com/claudioshiver) in [QwikDev/qwik#5168
-   docs: use import .css?inline instead of .css by [@&#8203;sapphi-red](https://togithub.com/sapphi-red) in [QwikDev/qwik#5161
-   fix(core.d.ts): export HTMLAttributes and DevJSX to fix TS4023 issue … by [@&#8203;gparlakov](https://togithub.com/gparlakov) in [QwikDev/qwik#5141
-   fix: excludedPath defaults for netlify edge by [@&#8203;adamdbradley](https://togithub.com/adamdbradley) in [QwikDev/qwik#5163
-   fix(labs): filter out (group layouts) by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5171
-   feat(core): added symbol name to error by [@&#8203;shairez](https://togithub.com/shairez) in [QwikDev/qwik#5182
-   feat: Bun Adapter by [@&#8203;EamonHeffernan](https://togithub.com/EamonHeffernan) in [QwikDev/qwik#5129
-   fix(qwik-auth): don't overwrite response headers in qwik auth by [@&#8203;Aslemammad](https://togithub.com/Aslemammad) in [QwikDev/qwik#5180
-   docs(qwik-city): Clean up docs for bun adapter by [@&#8203;EamonHeffernan](https://togithub.com/EamonHeffernan) in [QwikDev/qwik#5185
-   chore(qwik-auth): v0.1.2 by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5186
-   docs: added firebase to menu.md by [@&#8203;the-r3aper7](https://togithub.com/the-r3aper7) in [QwikDev/qwik#5183
-   chore: release 1.2.12 by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5187
-   chore: update Prisma versions package.json by [@&#8203;ruheni](https://togithub.com/ruheni) in [QwikDev/qwik#5184
-   docs: fix routing page - add missing attributes. by [@&#8203;hamatoyogi](https://togithub.com/hamatoyogi) in [QwikDev/qwik#5188
-   fix(qwik-city): do not write into a destroyed stream by [@&#8203;tuurbo](https://togithub.com/tuurbo) in [QwikDev/qwik#5172
-   fix(qwik-city): wait until action fully complete before resolving its… by [@&#8203;mhevery](https://togithub.com/mhevery) in [QwikDev/qwik#5190

##### New Contributors

-   [@&#8203;ilianiv](https://togithub.com/ilianiv) made their first contribution in [QwikDev/qwik#5159
-   [@&#8203;pipisso](https://togithub.com/pipisso) made their first contribution in [QwikDev/qwik#5169
-   [@&#8203;sapphi-red](https://togithub.com/sapphi-red) made their first contribution in [QwikDev/qwik#5161
-   [@&#8203;Aslemammad](https://togithub.com/Aslemammad) made their first contribution in [QwikDev/qwik#5180

**Full Changelog**: QwikDev/qwik@v1.2.11...v1.2.12

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9pm on sunday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ascorbic/unpic-img).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi45Ny4xIiwidXBkYXRlZEluVmVyIjoiMzYuOTcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants