-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix(jsx): add undefined to optional properties #12771
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
base: main
Are you sure you want to change the base?
Conversation
cf3b819
to
fa1e744
Compare
Size ReportBundles
Usages
|
@vue/compiler-ssr
@vue/compiler-core
@vue/reactivity
@vue/runtime-core
@vue/compiler-dom
@vue/runtime-dom
@vue/compiler-sfc
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
LGTM |
0dc9169
to
5372774
Compare
WalkthroughThe changes update TypeScript interface definitions for JSX intrinsic element attributes in Changes
Assessment against linked issues
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/runtime-dom/src/jsx.ts (1)
1-8
: Nitpick: Document theexactOptionalPropertyTypes
rationale
Consider enhancing the file header with a brief note explaining that these type changes support TypeScript’s--exactOptionalPropertyTypes
compiler option and reference issue #6068 for context.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
packages/runtime-dom/src/jsx.ts
(9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime-dom/src/jsx.ts (1)
packages/runtime-core/src/vnode.ts (1)
VNodeRef
(86-92)
🔇 Additional comments (6)
packages/runtime-dom/src/jsx.ts (6)
49-266
: ARIA Attributes: Explicitly includeundefined
All attributes inAriaAttributes
now correctly include| undefined
, satisfying--exactOptionalPropertyTypes
requirements. This change aligns with React’s patterns and improves type safety.
277-349
: Standard HTMLAttributes: Add| undefined
for optional props
The coreHTMLAttributes
interface has been updated so thatinnerHTML
,style
, and all standard HTML props explicitly allowundefined
. This ensures JSX consumers can passundefined
without type errors under strict optional property settings.
362-385
: Anchor & Area HTML Attributes: Explicitundefined
BothAnchorHTMLAttributes
andAreaHTMLAttributes
have had their optional props (href
,rel
, etc.) updated to include| undefined
. This is consistent with the PR goal and does not affect runtime behavior.
541-584
: InputHTMLAttributes: Include| undefined
across input props
TheInputHTMLAttributes
interface now explicitly adds| undefined
to every optional field (accept
,checked
,placeholder
, etc.). This ensures compatibility with stricter TS settings when passingundefined
to inputs.
835-862
: SVGAttributes: Explicitly allowundefined
on SVG props
All SVG-specific props (color
,height
,width
,role
,tabindex
, etc.) now include| undefined
, matching HTML and ARIA interfaces. Good coverage for strict optional types.
1425-1430
: ReservedProps: Add| undefined
to key/ref props
TheReservedProps
type (key
,ref
,ref_for
,ref_key
) now explicitly allowsundefined
, aligning with the rest of the JSX prop types.
What's the status with this PR? Do I need to add anything else? |
close #6068
Allow TypeScript projects that have
exactOptionalPropertyTypes
option enabled to be able to pass explicit props with a value ofundefined
https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes
Let's take for example React:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b30cd2bf71cdef25085038b4a556211c23c16489/types/react/index.d.ts#L3446-L3729
Checklist:
any | undefined
undefined | undefined
I advise reviewing one commit at a time.
Images
"exactOptionalPropertyTypes": false
"exactOptionalPropertyTypes": true
"exactOptionalPropertyTypes": true
and fixedsrc?: string | undefined
Related:
Links:
Summary by CodeRabbit