Skip to content
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

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

Merged
merged 43 commits into from
Apr 25, 2024
Merged
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
[autofix.ci] apply automated fixes
autofix-ci[bot] authored Oct 21, 2023
commit 6f0042edb7ebaa473e2be77774db55753a5cf568
2 changes: 1 addition & 1 deletion packages/dts-test/componentTypeExtensions.test-d.tsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ declare module 'vue' {
interface ComponentCustomOptions {
test?(n: number): void
}

interface GlobalDirectives {
test: Directive
}
12 changes: 9 additions & 3 deletions packages/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
@@ -1497,12 +1497,18 @@ describe('expose component types', () => {
expectType<Component>(parent.components!.child2)

// global components
expectType<Readonly<KeepAliveProps>>(new parent.components!.KeepAlive().$props)
expectType<Readonly<KeepAliveProps>>(
new parent.components!.KeepAlive().$props
)
expectType<Readonly<KeepAliveProps>>(new child.components!.KeepAlive().$props)

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

describe('directive typing', () => {
20 changes: 11 additions & 9 deletions packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ type IsDefaultMixinComponent<T> = T extends ComponentOptionsMixin
: false
: false

// TODO-CR check this
// TODO-CR check this
type MixinToOptionTypes<T> = T extends ComponentOptionsBase<
infer P,
infer B,
@@ -247,14 +247,16 @@ export type ComponentPublicInstance<
: (...args: any) => any,
options?: WatchOptions
): WatchStopHandle
} & ExposedKeys<P &
ShallowUnwrapRef<B> &
UnwrapNestedRefs<D> &
ExtractComputedReturns<C> &
M &
ComponentCustomProperties &
InjectToObject<I>,
Exposed>
} & ExposedKeys<
P &
ShallowUnwrapRef<B> &
UnwrapNestedRefs<D> &
ExtractComputedReturns<C> &
M &
ComponentCustomProperties &
InjectToObject<I>,
Exposed
>

export type PublicPropertiesMap = Record<
string,