types: setup tests for built d.ts files
This commit is contained in:
@@ -2,7 +2,7 @@ import { effect, ReactiveEffect, effectStack } from './effect'
|
||||
import { Ref, UnwrapRef } from './ref'
|
||||
import { isFunction, NOOP } from '@vue/shared'
|
||||
|
||||
export interface ComputedRef<T> extends WritableComputedRef<T> {
|
||||
export interface ComputedRef<T = any> extends WritableComputedRef<T> {
|
||||
readonly value: UnwrapRef<T>
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ const convert = <T extends unknown>(val: T): T =>
|
||||
|
||||
export function ref<T extends Ref>(raw: T): T
|
||||
export function ref<T>(raw: T): Ref<T>
|
||||
export function ref(raw: unknown) {
|
||||
export function ref<T = any>(): Ref<T>
|
||||
export function ref(raw?: unknown) {
|
||||
if (isRef(raw)) {
|
||||
return raw
|
||||
}
|
||||
|
||||
12
packages/runtime-core/jsx.d.ts
vendored
12
packages/runtime-core/jsx.d.ts
vendored
@@ -1,12 +0,0 @@
|
||||
declare namespace JSX {
|
||||
interface Element {}
|
||||
interface ElementClass {
|
||||
$props: {}
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
$props: {}
|
||||
}
|
||||
interface IntrinsicElements {
|
||||
[name: string]: any
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,11 @@ export interface ComponentOptionsBase<
|
||||
// type-only differentiator to separate OptionWihtoutProps from a constructor
|
||||
// type returned by createComponent() or FunctionalComponent
|
||||
call?: never
|
||||
// type-only differentiators for built-in Vnode types
|
||||
__isFragment?: never
|
||||
__isPortal?: never
|
||||
__isSuspense?: never
|
||||
__isKeepAlive?: never
|
||||
}
|
||||
|
||||
export type ComponentOptionsWithoutProps<
|
||||
|
||||
@@ -342,7 +342,8 @@ type CompileFunction = (
|
||||
|
||||
let compile: CompileFunction | undefined
|
||||
|
||||
export function registerRuntimeCompiler(_compile: CompileFunction) {
|
||||
// exported method uses any to avoid d.ts relying on the compiler types.
|
||||
export function registerRuntimeCompiler(_compile: any) {
|
||||
compile = _compile
|
||||
}
|
||||
|
||||
|
||||
@@ -81,20 +81,19 @@ export function h(
|
||||
children?: RawChildren
|
||||
): VNode
|
||||
|
||||
// keyed fragment
|
||||
export function h(type: typeof Fragment, children?: RawChildren): VNode
|
||||
// fragment
|
||||
export function h(type: typeof Fragment, children?: VNodeChildren): VNode
|
||||
export function h(
|
||||
type: typeof Fragment,
|
||||
props?: (RawProps & { key?: string | number }) | null,
|
||||
children?: RawChildren
|
||||
props?: RawProps | null,
|
||||
children?: VNodeChildren
|
||||
): VNode
|
||||
|
||||
// portal
|
||||
export function h(type: typeof Portal, children?: RawChildren): VNode
|
||||
// portal (target prop is required)
|
||||
export function h(
|
||||
type: typeof Portal,
|
||||
props?: (RawProps & { target: any }) | null,
|
||||
children?: RawChildren
|
||||
props: RawProps & { target: any },
|
||||
children: RawChildren
|
||||
): VNode
|
||||
|
||||
// suspense
|
||||
@@ -114,25 +113,22 @@ export function h(
|
||||
export function h(type: FunctionalComponent, children?: RawChildren): VNode
|
||||
export function h<P>(
|
||||
type: FunctionalComponent<P>,
|
||||
props?: (RawProps & P) | null,
|
||||
props?: (RawProps & P) | ({} extends P ? null : never),
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
|
||||
// stateful component
|
||||
export function h(type: ComponentOptions, children?: RawChildren): VNode
|
||||
export function h<P>(
|
||||
type: ComponentOptionsWithoutProps<P>,
|
||||
props?: (RawProps & P) | null,
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
export function h<P extends string>(
|
||||
type: ComponentOptionsWithArrayProps<P>,
|
||||
export function h(
|
||||
type: ComponentOptionsWithoutProps | ComponentOptionsWithArrayProps,
|
||||
props?: RawProps | null,
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
export function h<P>(
|
||||
type: ComponentOptionsWithObjectProps<P>,
|
||||
props?: (RawProps & ExtractPropTypes<P>) | null,
|
||||
export function h<O>(
|
||||
type: ComponentOptionsWithObjectProps<O>,
|
||||
props?:
|
||||
| (RawProps & ExtractPropTypes<O>)
|
||||
| ({} extends ExtractPropTypes<O> ? null : never),
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
|
||||
@@ -140,7 +136,7 @@ export function h<P>(
|
||||
export function h(type: Constructor, children?: RawChildren): VNode
|
||||
export function h<P>(
|
||||
type: Constructor<P>,
|
||||
props?: (RawProps & P) | null,
|
||||
props?: (RawProps & P) | ({} extends P ? null : never),
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
|
||||
|
||||
@@ -20,8 +20,14 @@ import { SuspenseBoundary, isSuspenseType } from './suspense'
|
||||
import { DirectiveBinding } from './directives'
|
||||
import { SuspenseImpl } from './suspense'
|
||||
|
||||
export const Fragment = Symbol(__DEV__ ? 'Fragment' : undefined)
|
||||
export const Portal = Symbol(__DEV__ ? 'Portal' : undefined)
|
||||
export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
|
||||
// type differentiator for h()
|
||||
__isFragment: true
|
||||
}
|
||||
export const Portal = (Symbol(__DEV__ ? 'Portal' : undefined) as any) as {
|
||||
// type differentiator for h()
|
||||
__isPortal: true
|
||||
}
|
||||
export const Text = Symbol(__DEV__ ? 'Text' : undefined)
|
||||
export const Comment = Symbol(__DEV__ ? 'Comment' : undefined)
|
||||
|
||||
@@ -47,7 +53,7 @@ export type VNodeTypes =
|
||||
export interface VNodeProps {
|
||||
[key: string]: any
|
||||
key?: string | number
|
||||
ref?: string | Ref | Function
|
||||
ref?: string | Ref | ((ref: object) => void)
|
||||
}
|
||||
|
||||
type VNodeChildAtom<HostNode, HostElement> =
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import { createRenderer, VNode } from '@vue/runtime-core'
|
||||
import {
|
||||
createRenderer,
|
||||
VNode,
|
||||
RootRenderFunction,
|
||||
App
|
||||
} from '@vue/runtime-core'
|
||||
import { nodeOps, TestNode, TestElement } from './nodeOps'
|
||||
import { patchProp } from './patchProp'
|
||||
import { serializeInner } from './serialize'
|
||||
|
||||
const { render, createApp } = createRenderer<TestNode, TestElement>({
|
||||
const { render: baseRender, createApp: baseCreateApp } = createRenderer({
|
||||
patchProp,
|
||||
...nodeOps
|
||||
})
|
||||
|
||||
export { render, createApp }
|
||||
export const render = baseRender as RootRenderFunction<TestNode, TestElement>
|
||||
export const createApp = baseCreateApp as () => App<TestElement>
|
||||
|
||||
// convenience for one-off render validations
|
||||
export function renderToString(vnode: VNode) {
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
// TODO
|
||||
export function renderToString() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user