Skip to content

types(defineComponent): DefineComponent refactor#4465

Closed
pikax wants to merge 53 commits into
vuejs:mainfrom
pikax:types/Merge_DefineComponent_and_Component
Closed

types(defineComponent): DefineComponent refactor#4465
pikax wants to merge 53 commits into
vuejs:mainfrom
pikax:types/Merge_DefineComponent_and_Component

Conversation

@pikax

@pikax pikax commented Aug 28, 2021

Copy link
Copy Markdown
Member

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

@znck znck Aug 31, 2021

Copy link
Copy Markdown
Member

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?

}[Event]
>
>) &
EmitVModelUpdate<P>

Copy link
Copy Markdown
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?

import { toRaw } from '@vue/reactivity'

export type Slot = (...args: any[]) => VNode[]
export type Slot = (...args: any[]) => VNode[] | VNode

Copy link
Copy Markdown
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[]

Comment thread yarn.lock
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yyx990803

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