Skip to content

Commit 9970b45

Browse files
committed
chore: add Transition and TransitionGroup to globalComponents
1 parent 057bad9 commit 9970b45

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

packages/runtime-dom/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import {
88
HydrationRenderer,
99
App,
1010
RootHydrateFunction,
11-
isRuntimeOnly
11+
isRuntimeOnly,
12+
DefineComponent
1213
} from '@vue/runtime-core'
1314
import { nodeOps } from './nodeOps'
1415
import { patchProp, forcePatchProp } from './patchProp'
1516
// Importing from the compiler, will be tree-shaken in prod
1617
import { isFunction, isString, isHTMLTag, isSVGTag, extend } from '@vue/shared'
18+
import { TransitionProps } from './components/Transition'
19+
import { TransitionGroupProps } from './components/TransitionGroup'
1720

1821
declare module '@vue/reactivity' {
1922
export interface RefUnwrapBailTypes {
@@ -22,6 +25,14 @@ declare module '@vue/reactivity' {
2225
}
2326
}
2427

28+
declare module '@vue/runtime-core' {
29+
interface GlobalComponents {
30+
// Note: if updating this, also update `types/globalComponents.d.ts`.
31+
Transition: DefineComponent<TransitionProps>
32+
TransitionGroup: DefineComponent<TransitionGroupProps>
33+
}
34+
}
35+
2536
const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps)
2637

2738
// lazy create the renderer - this makes core renderer logic tree-shakable
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Note: this file is auto concatenated to the end of the bundled d.ts during
2+
// build.
3+
4+
declare module '@vue/runtime-core' {
5+
interface GlobalComponents {
6+
Transition: DefineComponent<TransitionProps>
7+
TransitionGroup: DefineComponent<TransitionGroupProps>
8+
}
9+
}

test-dts/defineComponent.test-d.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
SetupContext,
1414
h,
1515
Directive,
16-
KeepAliveProps
16+
KeepAliveProps,
17+
TransitionProps
1718
} from './index'
1819

1920
describe('with object props', () => {
@@ -984,6 +985,10 @@ describe('expose component types', () => {
984985
// global components
985986
expectType<KeepAliveProps>(new parent.components!.KeepAlive().$props)
986987
expectType<KeepAliveProps>(new child.components!.KeepAlive().$props)
988+
989+
// runtime-dom components
990+
expectType<TransitionProps>(new parent.components!.Transition().$props)
991+
expectType<TransitionProps>(new parent.components!.Transition().$props)
987992
})
988993

989994
describe('directive typing', () => {

0 commit comments

Comments
 (0)