From f1f952768dce89018a0782ea65399452b5a32ccb Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Thu, 10 Nov 2022 18:57:03 -0800 Subject: [PATCH] types: register jsx types in runtime-dom to avoid breaking change --- packages/runtime-dom/package.json | 1 + packages/runtime-dom/types/jsx.d.ts | 2 +- pnpm-lock.yaml | 2 ++ test-dts/index.d.ts | 16 +++++++++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/runtime-dom/package.json b/packages/runtime-dom/package.json index bad5c894733..a1a37968dbc 100644 --- a/packages/runtime-dom/package.json +++ b/packages/runtime-dom/package.json @@ -35,6 +35,7 @@ }, "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-dom#readme", "dependencies": { + "@vue/jsx": "3.2.44", "@vue/shared": "3.2.44", "@vue/runtime-core": "3.2.44", "csstype": "^2.6.8" diff --git a/packages/runtime-dom/types/jsx.d.ts b/packages/runtime-dom/types/jsx.d.ts index 336ce12bb91..5ab31fd89e8 100644 --- a/packages/runtime-dom/types/jsx.d.ts +++ b/packages/runtime-dom/types/jsx.d.ts @@ -1 +1 @@ -export {} +import '@vue/jsx/register' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afb6f3f875e..74d0a1e5920 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -225,10 +225,12 @@ importers: packages/runtime-dom: specifiers: + '@vue/jsx': 3.2.44 '@vue/runtime-core': 3.2.44 '@vue/shared': 3.2.44 csstype: ^2.6.8 dependencies: + '@vue/jsx': link:../jsx '@vue/runtime-core': link:../runtime-core '@vue/shared': link:../shared csstype: 2.6.19 diff --git a/test-dts/index.d.ts b/test-dts/index.d.ts index 55238956200..57a6371f90f 100644 --- a/test-dts/index.d.ts +++ b/test-dts/index.d.ts @@ -1,7 +1,6 @@ // This directory contains a number of d.ts assertions // use \@ts-expect-error where errors are expected. -import '../packages/jsx/register' export * from '@vue/runtime-dom' export function describe(_name: string, _fn: () => void): void @@ -18,3 +17,18 @@ export type IsUnion = ( : true export type IsAny = 0 extends 1 & T ? true : false + +import { h } from '@vue/jsx' +// Duplicating @vue/jsx/register here to be able to run dts tests +// without building types. +declare global { + 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 {} + } +}