-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
feat(jsx-types): namespace JSX types #7083
Conversation
❌ Deploy Preview for vuejs-coverage failed.
|
Looks like dts tests run before building, trying to fix it. |
Notes: If we land this, to avoid disruption in userland we need to:
This is still technically a breaking change, especially for TSX users. To minimize the disruption, I think we should first start shipping this with auto registration by default in a minor, to allow Volar and existing projects to start using explicit global registration in advance. Then we remove auto global registration in a future release. |
@@ -0,0 +1,69 @@ | |||
/** @jsx h */ | |||
import { h } from '../packages/jsx' |
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.
@vue/jsx
instead of ../packages/jsx
does not work, don't know why.
|
||
// suppress ts:2669 | ||
export {} | ||
import '@vue/jsx/register' |
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 produces a warning that ./dist/jsx
does not exist. Since we are building in parallel, it is eventually created.
@@ -0,0 +1,35 @@ | |||
{ | |||
"name": "@vue/jsx", |
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.
I hope it's okay to use @vue/jsx
as package name.
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.
It's more like @vue/tsx
though 😂
Unless we are planning to add more functionalities to this package later.
} | ||
export interface IntrinsicAttributes extends ReservedProps {} | ||
export interface ElementChildrenAttribute { | ||
$slots: {} |
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.
Does this count as breaking change?
ElementChildrenAttribute
sets the name of children within props. https://www.typescriptlang.org/docs/handbook/jsx.html#children-type-checking
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.
Vuetify uses $children. Volar uses $slots but it isn't inside $props so doesn't count.
Also, can we use something like /** @jsxImportSource @vue/jsx */ See jsxImportSource example: |
This works. I think users should be required to explicitly specify it in tsconfig compilerOptions instead of implicitly adding it automatically in virtual code. The PR seems to have issues with // packages/jsx/jsx-runtime.d.ts
import { h } from './dist/jsx'
export namespace JSX {
interface Element extends h.JSX.Element { }
interface ElementClass extends h.JSX.ElementClass { }
interface ElementAttributesProperty
extends h.JSX.ElementAttributesProperty { }
interface IntrinsicElements extends h.JSX.IntrinsicElements { }
interface IntrinsicAttributes extends h.JSX.IntrinsicAttributes { }
interface ElementChildrenAttribute extends h.JSX.ElementChildrenAttribute { }
} |
Closing in favor of #7958 - restructured to |
@vue/jsx
@jsx
pragma@vue/jsx/register
Related #1033 #1034