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

Add missing select types and refactor #191

Merged
merged 4 commits into from
May 2, 2024

Conversation

JacopoPatroclo
Copy link

@JacopoPatroclo JacopoPatroclo commented Apr 18, 2024

This PR aims to fix this issue

First I've added the missing properties to the select jsx element typescript definition. I've added autocomplete and I've noticed that other properties were declared by the FormEvents interface so I've extended the select definition with that interface to avoid duplication.

Second I've removed all the duplicated undefined. In this case, they should be equivalent to ?:. Let me know @arthurfiorette if you see any issue with this and if I'm missing something.

Third I've added another test file that will be used in the future to check that all the types that this library provides are consistent with what is expected.

What still needs to be done:

  • Write more tests related to the types
  • Generate changelog (?)

@JacopoPatroclo JacopoPatroclo added the html-runtime Related to @kitajs/html label Apr 18, 2024
Copy link

changeset-bot bot commented Apr 18, 2024

🦋 Changeset detected

Latest commit: 192d48e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kitajs/html Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2fb3390) to head (192d48e).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #191   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines          457       457           
=========================================
  Hits           457       457           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arthurfiorette
Copy link
Member

Second I've removed all the duplicated undefined. In this case, they should be equivalent to ?:. Let me know @arthurfiorette if you see any issue with this and if I'm missing something.

Using ? and undefined | is required. Depending on the user's exactOptionalPropertyTypes configuration, it may force the user to define all properties as <div prop={undefined} />.

In kita's tsconfig this is indeed duplicated, but we cannot ensure all users follow our tsconfig.

packages/html/jsx.d.ts Outdated Show resolved Hide resolved
@arthurfiorette
Copy link
Member

To generate a changelog, run pnpm changeset in the project's root.

https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md

@arthurfiorette
Copy link
Member

Write more tests related to the types

We have two paths to follow here:

  1. We find a complete test spec somewhere and copy/paste it here.
  2. We wait for type issues to come and only merge them if they also add their tests here.

Adding more type tests without a issues we will probably end up with incorrect tests.

@JacopoPatroclo
Copy link
Author

Write more tests related to the types

We have two paths to follow here:

  1. We find a complete test spec somewhere and copy/paste it here.
  2. We wait for type issues to come and only merge them if they also add their tests here.

Adding more type tests without issues we will probably end up with incorrect tests.

That's a valid point. I'll invest a little bit of time looking for a standard spec that we could use.
If I can't find anything that fits; we should grow that particular test suite organically as you suggested (2)

@JacopoPatroclo
Copy link
Author

@arthurfiorette I couldn't find any "standard" jsx definition for dom elements rendered on the server. There is a heavy focus (obviously) on client-side specific type definitions that are not good for the context of this library. We should roll our type definitions for now.

Ex. The onselect property is often defined as a function and not a string.

@arthurfiorette
Copy link
Member

Awesome! As always, thanks for your work @JacopoPatroclo! Is this ready to merge?

@JacopoPatroclo
Copy link
Author

Awesome! As always, thanks for your work @JacopoPatroclo! Is this ready to merge?

I think so, maybe a squash merge is necessary to "hide" some "wrong" commits.

@arthurfiorette arthurfiorette merged commit af06ac8 into kitajs:master May 2, 2024
8 checks passed
@arthurfiorette arthurfiorette mentioned this pull request May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
html-runtime Related to @kitajs/html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add onchange and oninput events for the select tag
2 participants