mirror of https://github.com/vuejs/core.git
fix(types/jsx): move JSX DOM types back to `@vue/runtime-dom` (#7979)
This commit is contained in:
parent
ff60b933ae
commit
ffe679c490
|
@ -252,3 +252,5 @@ export const initDirectivesForSSR = __SSR__
|
||||||
// re-export everything from core
|
// re-export everything from core
|
||||||
// h, Component, reactivity API, nextTick, flags & types
|
// h, Component, reactivity API, nextTick, flags & types
|
||||||
export * from '@vue/runtime-core'
|
export * from '@vue/runtime-core'
|
||||||
|
|
||||||
|
export * from './jsx'
|
||||||
|
|
|
@ -1319,3 +1319,17 @@ type EventHandlers<E> = {
|
||||||
? E[K]
|
? E[K]
|
||||||
: (payload: E[K]) => void
|
: (payload: E[K]) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { VNodeRef } from '@vue/runtime-core'
|
||||||
|
|
||||||
|
export type ReservedProps = {
|
||||||
|
key?: string | number | symbol
|
||||||
|
ref?: VNodeRef
|
||||||
|
ref_for?: boolean
|
||||||
|
ref_key?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NativeElements = {
|
||||||
|
[K in keyof IntrinsicElementAttributes]: IntrinsicElementAttributes[K] &
|
||||||
|
ReservedProps
|
||||||
|
}
|
|
@ -1,17 +1,9 @@
|
||||||
import { VNode, VNodeRef } from '@vue/runtime-dom'
|
import type {
|
||||||
import { IntrinsicElementAttributes } from './dom'
|
VNode,
|
||||||
|
IntrinsicElementAttributes,
|
||||||
export type ReservedProps = {
|
ReservedProps,
|
||||||
key?: string | number | symbol
|
NativeElements
|
||||||
ref?: VNodeRef
|
} from '@vue/runtime-dom'
|
||||||
ref_for?: boolean
|
|
||||||
ref_key?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NativeElements = {
|
|
||||||
[K in keyof IntrinsicElementAttributes]: IntrinsicElementAttributes[K] &
|
|
||||||
ReservedProps
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSX namespace for usage with @jsxImportsSource directive
|
* JSX namespace for usage with @jsxImportsSource directive
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
// global JSX namespace registration
|
// global JSX namespace registration
|
||||||
// somehow we have to copy=pase the jsx-runtime types here to make TypeScript happy
|
// somehow we have to copy=pase the jsx-runtime types here to make TypeScript happy
|
||||||
import { VNode, VNodeRef } from '@vue/runtime-dom'
|
import type {
|
||||||
import { IntrinsicElementAttributes } from './jsx-runtime/dom'
|
VNode,
|
||||||
|
IntrinsicElementAttributes,
|
||||||
export * from './jsx-runtime/dom'
|
ReservedProps,
|
||||||
|
NativeElements
|
||||||
export type ReservedProps = {
|
} from '@vue/runtime-dom'
|
||||||
key?: string | number | symbol
|
|
||||||
ref?: VNodeRef
|
|
||||||
ref_for?: boolean
|
|
||||||
ref_key?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NativeElements = {
|
|
||||||
[K in keyof IntrinsicElementAttributes]: IntrinsicElementAttributes[K] &
|
|
||||||
ReservedProps
|
|
||||||
}
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
|
|
|
@ -2,5 +2,3 @@
|
||||||
// imports the global JSX namespace registration for compat.
|
// imports the global JSX namespace registration for compat.
|
||||||
// TODO: remove in 3.4
|
// TODO: remove in 3.4
|
||||||
import '../jsx'
|
import '../jsx'
|
||||||
|
|
||||||
export * from '../jsx-runtime/dom'
|
|
||||||
|
|
|
@ -88,7 +88,21 @@ function patchTypes(pkg) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isExported = new Set()
|
||||||
const shouldRemoveExport = new Set()
|
const shouldRemoveExport = new Set()
|
||||||
|
|
||||||
|
// pass 0: check all exported types
|
||||||
|
for (const node of ast.program.body) {
|
||||||
|
if (node.type === 'ExportNamedDeclaration' && !node.source) {
|
||||||
|
for (let i = 0; i < node.specifiers.length; i++) {
|
||||||
|
const spec = node.specifiers[i]
|
||||||
|
if (spec.type === 'ExportSpecifier') {
|
||||||
|
isExported.add(spec.local.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// pass 1: remove internals + add exports
|
// pass 1: remove internals + add exports
|
||||||
for (const node of ast.program.body) {
|
for (const node of ast.program.body) {
|
||||||
if (
|
if (
|
||||||
|
@ -96,10 +110,13 @@ function patchTypes(pkg) {
|
||||||
node.type === 'TSInterfaceDeclaration') &&
|
node.type === 'TSInterfaceDeclaration') &&
|
||||||
!node.id.name.startsWith(`_`)
|
!node.id.name.startsWith(`_`)
|
||||||
) {
|
) {
|
||||||
shouldRemoveExport.add(node.id.name)
|
const name = node.id.name
|
||||||
|
shouldRemoveExport.add(name)
|
||||||
if (!removeInternal(node)) {
|
if (!removeInternal(node)) {
|
||||||
|
if (isExported.has(name)) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
s.prependLeft(node.start, `export `)
|
s.prependLeft(node.start, `export `)
|
||||||
|
}
|
||||||
// traverse further for internal properties
|
// traverse further for internal properties
|
||||||
if (node.type === 'TSInterfaceDeclaration') {
|
if (node.type === 'TSInterfaceDeclaration') {
|
||||||
node.body.body.forEach(removeInternal)
|
node.body.body.forEach(removeInternal)
|
||||||
|
|
Loading…
Reference in New Issue