Skip to content

types(defineComponent): Support for GlobalComponents, typed Directives and respect expose on defineComponent #3399

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

Merged
merged 43 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e2cac07
types(defineComponent): support for expose component types
pikax Mar 9, 2021
3ccdc0b
chore: add directive typing test
pikax Mar 9, 2021
e140b07
chore: exposed type suppor
pikax Mar 9, 2021
5f49e9c
chore: add global directive type
pikax Mar 9, 2021
fbb62bc
chore: fix tests
pikax Mar 9, 2021
b10bc77
chore: clean dup code
pikax Mar 10, 2021
d0b13fa
chore: add GlobalComponents and GlobalDirectives
pikax Mar 11, 2021
057bad9
chore: add Suspense, KeepAlive, Teleport to GlobalComponents
pikax Mar 13, 2021
9970b45
chore: add Transition and TransitionGroup to globalComponents
pikax Mar 13, 2021
2498929
chore: add BaseTransition ass globalComponent
pikax Mar 13, 2021
b792c6c
chore: add VShow as a globalDirective
pikax Mar 13, 2021
980dbf3
chore: add BaseTransition
pikax Mar 13, 2021
200838d
chore: correct interface with file name
pikax Mar 14, 2021
dffd7c9
Merge branch 'master' into types/refactor_defineComponent
pikax Mar 30, 2021
08c1217
chore: wrap component to get the type
pikax Mar 30, 2021
ca63ffa
chore: typed directives + VModel directive
pikax Apr 15, 2021
16352ca
chore: move arg after modifiers and add tests
pikax Apr 18, 2021
7754d7e
chore: improve tests
pikax Apr 18, 2021
6558afd
chore: add vOn directive as global
pikax Apr 23, 2021
99741b8
chore: vmodel WIP
pikax Apr 25, 2021
675a642
Merge branch 'master-upstream' into types/refactor_defineComponent
pikax Aug 15, 2021
5573d90
chore: remove bad import and fix compat render type
pikax Aug 15, 2021
a3408d7
chore: remove type
pikax Aug 15, 2021
3ecd0cb
Merge branch 'master-upstream' into types/refactor_defineComponent
pikax Jan 1, 2022
3757760
Merge branch 'main-upstream' into types/refactor_defineComponent
pikax Jan 27, 2022
37593c9
minor: fix ssrCompiler test
pikax Feb 5, 2022
b268011
minor: remove breaking code -.-'
pikax Feb 5, 2022
5b82ea4
Merge branch 'main-upstream' into types/refactor_defineComponent
pikax Feb 5, 2022
1269ab1
minor: fix tests and remove unnecessary defineComponent
pikax Feb 5, 2022
50b17d4
chore: remove added defineComponent
pikax Feb 5, 2022
90a5872
Merge branch 'main-upstream' into types/refactor_defineComponent
pikax May 11, 2022
fa99b42
fix bad merge
pikax May 11, 2022
a59d3c5
Merge branch 'main-upstream' into types/refactor_defineComponent
pikax May 12, 2022
30dd076
Merge branch 'main' into pr/3399
pikax Oct 21, 2023
6f0042e
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 21, 2023
f9754a6
format and remove comment
pikax Oct 21, 2023
9b98398
chore: remove RawOptions from defineComponent
pikax Oct 21, 2023
794f6c1
Merge branch 'main' into pr/3399
pikax Nov 17, 2023
34a5391
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 17, 2023
6eda2d5
chore: fix vuetify usage
pikax Nov 22, 2023
3b5b8f2
chore: Merge branch 'minor' into pr/3399
pikax Jan 21, 2024
93b94c2
Merge branch 'minor' into types/refactor_defineComponent
pikax Apr 17, 2024
af1c810
chore: Merge branch 'minor' into types/refactor_defineComponent
yyx990803 Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add Transition and TransitionGroup to globalComponents
  • Loading branch information
pikax committed Mar 13, 2021
commit 9970b4510b46fd3fdc9e5a229439e0776fb39517
13 changes: 12 additions & 1 deletion packages/runtime-dom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import {
HydrationRenderer,
App,
RootHydrateFunction,
isRuntimeOnly
isRuntimeOnly,
DefineComponent
} from '@vue/runtime-core'
import { nodeOps } from './nodeOps'
import { patchProp, forcePatchProp } from './patchProp'
// Importing from the compiler, will be tree-shaken in prod
import { isFunction, isString, isHTMLTag, isSVGTag, extend } from '@vue/shared'
import { TransitionProps } from './components/Transition'
import { TransitionGroupProps } from './components/TransitionGroup'

declare module '@vue/reactivity' {
export interface RefUnwrapBailTypes {
Expand All @@ -22,6 +25,14 @@ declare module '@vue/reactivity' {
}
}

declare module '@vue/runtime-core' {
interface GlobalComponents {
// Note: if updating this, also update `types/globalComponents.d.ts`.
Transition: DefineComponent<TransitionProps>
TransitionGroup: DefineComponent<TransitionGroupProps>
}
}

const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps)

// lazy create the renderer - this makes core renderer logic tree-shakable
Expand Down
9 changes: 9 additions & 0 deletions packages/runtime-dom/types/globalComponents.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Note: this file is auto concatenated to the end of the bundled d.ts during
// build.

declare module '@vue/runtime-core' {
interface GlobalComponents {
Transition: DefineComponent<TransitionProps>
TransitionGroup: DefineComponent<TransitionGroupProps>
}
}
7 changes: 6 additions & 1 deletion test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
SetupContext,
h,
Directive,
KeepAliveProps
KeepAliveProps,
TransitionProps
} from './index'

describe('with object props', () => {
Expand Down Expand Up @@ -984,6 +985,10 @@ describe('expose component types', () => {
// global components
expectType<KeepAliveProps>(new parent.components!.KeepAlive().$props)
expectType<KeepAliveProps>(new child.components!.KeepAlive().$props)

// runtime-dom components
expectType<TransitionProps>(new parent.components!.Transition().$props)
expectType<TransitionProps>(new parent.components!.Transition().$props)
})

describe('directive typing', () => {
Expand Down