-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 optional property types #6872
base: main
Are you sure you want to change the base?
Conversation
c04c9f6
to
30e77c7
Compare
@@ -59,7 +59,7 @@ export interface DOMProps { | |||
/** | |||
* The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). | |||
*/ | |||
id?: string | |||
id?: string | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks correct, but is really going to need to exist in so many more places
https://github.com/microsoft/TypeScript/blob/a86b5e2b01075db5046521958a3e0b905b4ca667/tests/lib/react18/react18.d.ts#L1863
Any way we can use the type from the original set instead of creating our own? maybe extends Pick<HTMLElement, 'id'>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The focus of this PR is to just fix the public API. I don't see anything wrong with adding | undefined
in more places, but that's #1890.
Updated to use extends
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I guess i'm worried about potential regressions, and I'm also not sure that this is really all there is to fix in the public API, seems like too small a change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, there's most likely more, I only submitted the changes necessary to unblock our particular cocktail of Spectrum 😛 I'll create more PRs in the future as I run into other issues.
Hopefully #1890 will be addressed soon, but until then, one option could be to add a quick smoke test, that just lists every single package as a dependency and runs tsc
with skipLibCheck: false
, strict: true
and exactOptionalPropertyTypes: true
? This will allow you to make sure that the public API is clean, without switching the whole monorepo to exactOptionalPropertyTypes: true
.
5d21ca7
to
0ad564b
Compare
Addresses #1890 (comment)
✅ Pull Request Checklist:
📝 Test Instructions:
Install any of
react-spectrum
packages that bring in@internationalized/date
and@react-types/shared
, and type-check the project withexactOptionalPropertyTypes: true
.hourCycle
causes this:DOMProps
causes this: