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(jsx): add undefined to optional properties #12771

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iamandrewluca
Copy link

@iamandrewluca iamandrewluca commented Jan 22, 2025

close #6068

Allow TypeScript projects that have exactOptionalPropertyTypes option enabled to be able to pass explicit props with a value of undefined

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:

  • Ensure no any | undefined
  • Ensure no undefined | undefined
  • Run format after review

I advise reviewing one commit at a time.

  • In the first commit, I change all multiline unions to single-line unions to make it easier to review changes (same line diff).
  • The second commit adds undefined.
  • The third one formats the file back.
Images

"exactOptionalPropertyTypes": false

image

"exactOptionalPropertyTypes": true

image image

"exactOptionalPropertyTypes": true and fixed src?: string | undefined

image image

Related:

Links:

@iamandrewluca iamandrewluca force-pushed the fix/runtime-dom-optional branch 4 times, most recently from c90aba2 to cf3b819 Compare February 5, 2025 17:05
@iamandrewluca iamandrewluca force-pushed the fix/runtime-dom-optional branch from cf3b819 to fa1e744 Compare February 5, 2025 17:17
Copy link

github-actions bot commented Feb 6, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 38 kB 34.3 kB
vue.global.prod.js 158 kB 57.8 kB 51.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.4 kB 18.2 kB 16.6 kB
createApp 54.3 kB 21.2 kB 19.3 kB
createSSRApp 58.5 kB 22.9 kB 20.9 kB
defineCustomElement 59.2 kB 22.8 kB 20.7 kB
overall 68.4 kB 26.3 kB 24 kB

Copy link

pkg-pr-new bot commented Feb 6, 2025

Open in Stackblitz

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@12771

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@12771

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@12771

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@12771

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@12771

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@12771

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@12771

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@12771

@vue/shared

npm i https://pkg.pr.new/@vue/shared@12771

vue

npm i https://pkg.pr.new/vue@12771

@vue/compat

npm i https://pkg.pr.new/@vue/compat@12771

commit: 0dc9169

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: types 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Feb 6, 2025
@edison1105 edison1105 requested a review from jh-leong February 6, 2025 01:01
@edison1105 edison1105 changed the title fix(runtime-dom): add undefined to optional properties fix(jsx): add undefined to optional properties Feb 6, 2025
@jh-leong
Copy link
Member

jh-leong commented Feb 6, 2025

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing support in @vue/runtime-dom for TypeScript's --exactOptionalPropertyTypes option
3 participants