refactor(types): mark internal API exports and exclude from d.ts

BREAKING CHANGE: Internal APIs are now excluded from type decalrations.
This commit is contained in:
Evan You
2020-04-30 17:04:35 -04:00
parent a5bb1d02b7
commit c9bf7ded2e
28 changed files with 209 additions and 96 deletions

View File

@@ -6,6 +6,10 @@ interface CompiledSlotDescriptor {
fn: Slot
}
/**
* Compiler runtime helper for creating dynamic slots object
* @internal
*/
export function createSlots(
slots: Record<string, Slot>,
dynamicSlots: (

View File

@@ -1,31 +1,46 @@
import { VNodeChild } from '../vnode'
import { isArray, isString, isObject } from '@vue/shared'
// v-for string
/**
* v-for string
* @internal
*/
export function renderList(
source: string,
renderItem: (value: string, index: number) => VNodeChild
): VNodeChild[]
// v-for number
/**
* v-for number
* @internal
*/
export function renderList(
source: number,
renderItem: (value: number, index: number) => VNodeChild
): VNodeChild[]
// v-for array
/**
* v-for array
* @internal
*/
export function renderList<T>(
source: T[],
renderItem: (value: T, index: number) => VNodeChild
): VNodeChild[]
// v-for iterable
/**
* v-for iterable
* @internal
*/
export function renderList<T>(
source: Iterable<T>,
renderItem: (value: T, index: number) => VNodeChild
): VNodeChild[]
// v-for object
/**
* v-for object
* @internal
*/
export function renderList<T>(
source: T,
renderItem: <K extends keyof T>(

View File

@@ -10,6 +10,10 @@ import {
import { PatchFlags } from '@vue/shared'
import { warn } from '../warning'
/**
* Compiler runtime helper for rendering <slot/>
* @internal
*/
export function renderSlot(
slots: Slots,
name: string,

View File

@@ -12,12 +12,18 @@ import { warn } from '../warning'
const COMPONENTS = 'components'
const DIRECTIVES = 'directives'
/**
* @internal
*/
export function resolveComponent(name: string): Component | string | undefined {
return resolveAsset(COMPONENTS, name) || name
}
export const NULL_DYNAMIC_COMPONENT = Symbol()
/**
* @internal
*/
export function resolveDynamicComponent(
component: unknown
): Component | string | typeof NULL_DYNAMIC_COMPONENT {
@@ -29,6 +35,9 @@ export function resolveDynamicComponent(
}
}
/**
* @internal
*/
export function resolveDirective(name: string): Directive | undefined {
return resolveAsset(DIRECTIVES, name)
}

View File

@@ -7,15 +7,24 @@ import { withCtx } from './withRenderContext'
export let currentScopeId: string | null = null
const scopeIdStack: string[] = []
/**
* @internal
*/
export function pushScopeId(id: string) {
scopeIdStack.push((currentScopeId = id))
}
/**
* @internal
*/
export function popScopeId() {
scopeIdStack.pop()
currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null
}
/**
* @internal
*/
export function withScopeId(id: string): <T extends Function>(fn: T) => T {
return ((fn: Function) =>
withCtx(function(this: any) {

View File

@@ -1,7 +1,10 @@
import { isObject } from '@vue/shared'
import { warn } from '../warning'
// For prefixing keys in v-on="obj" with "on"
/**
* For prefixing keys in v-on="obj" with "on"
* @internal
*/
export function toHandlers(obj: Record<string, any>): Record<string, any> {
const ret: Record<string, any> = {}
if (__DEV__ && !isObject(obj)) {

View File

@@ -5,6 +5,10 @@ import {
} from '../componentRenderUtils'
import { ComponentInternalInstance } from '../component'
/**
* Wrap a slot function to memoize current rendering instance
* @internal
*/
export function withCtx(
fn: Slot,
ctx: ComponentInternalInstance | null = currentRenderingInstance