Skip to content

Commit

Permalink
Revert "fix(types): propagate type parameter constraints for TypeScri…
Browse files Browse the repository at this point in the history
…pt 4.8 (vuejs#6351)"

This reverts commit 516fabb.
  • Loading branch information
yyx990803 committed Jul 12, 2023
1 parent 24d98f0 commit 37a14a5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-core/src/apiCreateApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ComponentPublicInstance
} from './componentPublicInstance'
import { Directive, validateDirectiveName } from './directives'
import { RendererElement, RootRenderFunction } from './renderer'
import { RootRenderFunction } from './renderer'
import { InjectionKey } from './apiInject'
import { warn } from './warning'
import { createVNode, cloneVNode, VNode } from './vnode'
Expand Down Expand Up @@ -196,7 +196,7 @@ export type CreateAppFunction<HostElement> = (

let uid = 0

export function createAppAPI<HostElement extends RendererElement>(
export function createAppAPI<HostElement>(
render: RootRenderFunction<HostElement>,
hydrate?: RootHydrateFunction
): CreateAppFunction<HostElement> {
Expand Down
16 changes: 4 additions & 12 deletions packages/runtime-core/src/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { ComponentPublicInstance } from './componentPublicInstance'
import { mapCompatDirectiveHook } from './compat/customDirective'
import { pauseTracking, resetTracking } from '@vue/reactivity'
import { traverse } from './apiWatch'
import { RendererElement } from './renderer'

export interface DirectiveBinding<V = any> {
instance: ComponentPublicInstance | null
Expand All @@ -32,11 +31,7 @@ export interface DirectiveBinding<V = any> {
dir: ObjectDirective<any, V>
}

export type DirectiveHook<
T extends RendererElement = any,
Prev = VNode<any, T> | null,
V = any
> = (
export type DirectiveHook<T = any, Prev = VNode<any, T> | null, V = any> = (
el: T,
binding: DirectiveBinding<V>,
vnode: VNode<any, T>,
Expand All @@ -48,7 +43,7 @@ export type SSRDirectiveHook = (
vnode: VNode
) => Data | undefined

export interface ObjectDirective<T extends RendererElement = any, V = any> {
export interface ObjectDirective<T = any, V = any> {
created?: DirectiveHook<T, null, V>
beforeMount?: DirectiveHook<T, null, V>
mounted?: DirectiveHook<T, null, V>
Expand All @@ -60,12 +55,9 @@ export interface ObjectDirective<T extends RendererElement = any, V = any> {
deep?: boolean
}

export type FunctionDirective<
T extends RendererElement = any,
V = any
> = DirectiveHook<T, any, V>
export type FunctionDirective<T = any, V = any> = DirectiveHook<T, any, V>

export type Directive<T extends RendererElement = any, V = any> =
export type Directive<T = any, V = any> =
| ObjectDirective<T, V>
| FunctionDirective<T, V>

Expand Down
8 changes: 4 additions & 4 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type RootRenderFunction<HostElement = RendererElement> = (

export interface RendererOptions<
HostNode = RendererNode,
HostElement extends RendererElement = RendererElement
HostElement = RendererElement
> {
patchProp(
el: HostElement,
Expand Down Expand Up @@ -145,7 +145,7 @@ export interface RendererElement extends RendererNode {}
// to optimize bundle size.
export interface RendererInternals<
HostNode = RendererNode,
HostElement extends RendererElement = RendererElement
HostElement = RendererElement
> {
p: PatchFn
um: UnmountFn
Expand Down Expand Up @@ -295,7 +295,7 @@ export const queuePostRenderEffect = __FEATURE_SUSPENSE__
*/
export function createRenderer<
HostNode = RendererNode,
HostElement extends RendererElement = RendererElement
HostElement = RendererElement
>(options: RendererOptions<HostNode, HostElement>) {
return baseCreateRenderer<HostNode, HostElement>(options)
}
Expand All @@ -312,7 +312,7 @@ export function createHydrationRenderer(
// overload 1: no hydration
function baseCreateRenderer<
HostNode = RendererNode,
HostElement extends RendererElement = RendererElement
HostElement = RendererElement
>(options: RendererOptions<HostNode, HostElement>): Renderer<HostElement>

// overload 2: with hydration
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export type VNodeNormalizedChildren =

export interface VNode<
HostNode = RendererNode,
HostElement extends RendererElement = RendererElement,
HostElement = RendererElement,
ExtraProps = { [key: string]: any }
> {
/**
Expand Down Expand Up @@ -613,7 +613,7 @@ export function guardReactiveProps(props: (Data & VNodeProps) | null) {
: props
}

export function cloneVNode<T extends RendererNode, U extends RendererElement>(
export function cloneVNode<T, U>(
vnode: VNode<T, U>,
extraProps?: (Data & VNodeProps) | null,
mergeRef = false
Expand Down

0 comments on commit 37a14a5

Please sign in to comment.