-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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): DefineComponent refactor #4465
types(defineComponent): DefineComponent refactor #4465
Conversation
# Conflicts: # packages/runtime-core/src/component.ts # packages/runtime-core/src/componentEmits.ts # packages/runtime-core/src/componentOptions.ts # test-dts/h.test-d.ts # yarn.lock
# Conflicts: # packages/runtime-core/src/componentOptions.ts
# Conflicts: # packages/runtime-core/src/component.ts # packages/runtime-core/src/componentOptions.ts # packages/runtime-core/src/componentProps.ts
# Conflicts: # packages/runtime-core/src/componentOptions.ts # packages/runtime-core/src/componentPublicInstance.ts # packages/runtime-dom/src/directives/vModel.ts # packages/runtime-dom/src/directives/vOn.ts # packages/runtime-dom/src/index.ts
# Conflicts: # packages/runtime-core/src/componentOptions.ts
…fineComponent_and_Component # Conflicts: # packages/runtime-core/src/apiDefineComponent.ts # packages/runtime-core/src/component.ts # packages/runtime-core/src/componentEmits.ts # packages/runtime-core/src/componentOptions.ts # packages/runtime-core/src/h.ts
…s/Merge_DefineComponent_and_Component # Conflicts: # packages/runtime-core/src/apiDefineComponent.ts
…_DefineComponent_and_Component # Conflicts: # packages/runtime-core/src/apiDefineComponent.ts # packages/runtime-core/src/componentOptions.ts # packages/runtime-core/src/componentPublicInstance.ts # test-dts/defineComponent.test-d.tsx
* | ||
* declare module '@vue/runtime-core' { | ||
* interface GlobalDirectives { | ||
* VTooltip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should suggest using camelCase or kebab-case version of directive (without the v prefix); similar to local registration in component options.
components?: Record<string, Component> | ||
directives?: Record<string, Directive> | ||
components?: LC | ||
directives?: Directives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be called LD
to align with components option?
Slots = {}, | ||
// Allows to expose public API properties, this bypasses Data/Computed/Methods, | ||
// easier to declare manually | ||
Bindings extends Record<string, unknown> = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public API of a component is props, emits, slots and expose. What do you think about Expose
being 4th param?
@@ -66,7 +90,8 @@ export type EmitFn< | |||
? (event: key, ...args: Args) => void | |||
: (event: key, ...args: any[]) => void | |||
}[Event] | |||
> | |||
>) & | |||
EmitVModelUpdate<P> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this adding emit('update:foo')
for every prop even if they don't have an emit declared for it?
@@ -22,16 +22,37 @@ import { isHmrUpdating } from './hmr' | |||
import { DeprecationTypes, isCompatEnabled } from './compat/compatConfig' | |||
import { toRaw } from '@vue/reactivity' | |||
|
|||
export type Slot = (...args: any[]) => VNode[] | |||
export type Slot = (...args: any[]) => VNode[] | VNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h(Foo, () => {...}
can return a single VNode but slots.default()
is normalised so should always be VNode[]
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86" | ||
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ== | ||
|
||
typescript@~4.3.5: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closed in favor of #9556 |
This PR aims to refactor
DefineComponent
to merge it withComponent
typeBecause this will break the prev DefineComponent I've merged a few PR into this one
Merged PR
#2164
#2693
#3399
#2494