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): DefineComponent refactor #4465

Closed

Conversation

pikax
Copy link
Member

@pikax pikax commented Aug 28, 2021

This PR aims to refactor DefineComponent to merge it with Component type

Because this will break the prev DefineComponent I've merged a few PR into this one

Merged PR

#2164
#2693
#3399
#2494

# 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
pikax added 13 commits July 16, 2021 15:41
# 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
Copy link
Member

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
Copy link
Member

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> = {},
Copy link
Member

@znck znck Aug 31, 2021

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>
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyx990803
Copy link
Member

Closed in favor of #9556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Rejected
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants