feat(types): adjust type exports for manual render function and tooling usage
- v-model and v-show directives are now exposed as public - compiler-used runtime helpers are now exposed for TS tooling, but marked as @private close #1329
This commit is contained in:
parent
9b5d13e598
commit
e4dc03a8b1
@ -40,6 +40,10 @@
|
|||||||
"tsdocMessageReporting": {
|
"tsdocMessageReporting": {
|
||||||
"default": {
|
"default": {
|
||||||
"logLevel": "warning"
|
"logLevel": "warning"
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdoc-undefined-tag": {
|
||||||
|
"logLevel": "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ interface CompiledSlotDescriptor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiler runtime helper for creating dynamic slots object
|
* Compiler runtime helper for creating dynamic slots object
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function createSlots(
|
export function createSlots(
|
||||||
slots: Record<string, Slot>,
|
slots: Record<string, Slot>,
|
||||||
|
@ -3,7 +3,7 @@ import { isArray, isString, isObject } from '@vue/shared'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* v-for string
|
* v-for string
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function renderList(
|
export function renderList(
|
||||||
source: string,
|
source: string,
|
||||||
@ -12,7 +12,6 @@ export function renderList(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* v-for number
|
* v-for number
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export function renderList(
|
export function renderList(
|
||||||
source: number,
|
source: number,
|
||||||
@ -21,7 +20,6 @@ export function renderList(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* v-for array
|
* v-for array
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export function renderList<T>(
|
export function renderList<T>(
|
||||||
source: T[],
|
source: T[],
|
||||||
@ -30,7 +28,6 @@ export function renderList<T>(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* v-for iterable
|
* v-for iterable
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export function renderList<T>(
|
export function renderList<T>(
|
||||||
source: Iterable<T>,
|
source: Iterable<T>,
|
||||||
@ -39,7 +36,6 @@ export function renderList<T>(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* v-for object
|
* v-for object
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export function renderList<T>(
|
export function renderList<T>(
|
||||||
source: T,
|
source: T,
|
||||||
@ -50,7 +46,9 @@ export function renderList<T>(
|
|||||||
) => VNodeChild
|
) => VNodeChild
|
||||||
): VNodeChild[]
|
): VNodeChild[]
|
||||||
|
|
||||||
// actual implementation
|
/**
|
||||||
|
* Actual implementation
|
||||||
|
*/
|
||||||
export function renderList(
|
export function renderList(
|
||||||
source: any,
|
source: any,
|
||||||
renderItem: (...args: any[]) => VNodeChild
|
renderItem: (...args: any[]) => VNodeChild
|
||||||
|
@ -12,7 +12,7 @@ import { warn } from '../warning'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiler runtime helper for rendering <slot/>
|
* Compiler runtime helper for rendering <slot/>
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function renderSlot(
|
export function renderSlot(
|
||||||
slots: Slots,
|
slots: Slots,
|
||||||
|
@ -12,12 +12,18 @@ import { warn } from '../warning'
|
|||||||
const COMPONENTS = 'components'
|
const COMPONENTS = 'components'
|
||||||
const DIRECTIVES = 'directives'
|
const DIRECTIVES = 'directives'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
export function resolveComponent(name: string): Component | string | undefined {
|
export function resolveComponent(name: string): Component | string | undefined {
|
||||||
return resolveAsset(COMPONENTS, name) || name
|
return resolveAsset(COMPONENTS, name) || name
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NULL_DYNAMIC_COMPONENT = Symbol()
|
export const NULL_DYNAMIC_COMPONENT = Symbol()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
export function resolveDynamicComponent(
|
export function resolveDynamicComponent(
|
||||||
component: unknown
|
component: unknown
|
||||||
): Component | string | typeof NULL_DYNAMIC_COMPONENT {
|
): Component | string | typeof NULL_DYNAMIC_COMPONENT {
|
||||||
@ -29,11 +35,17 @@ export function resolveDynamicComponent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
export function resolveDirective(name: string): Directive | undefined {
|
export function resolveDirective(name: string): Directive | undefined {
|
||||||
return resolveAsset(DIRECTIVES, name)
|
return resolveAsset(DIRECTIVES, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// overload 1: components
|
/**
|
||||||
|
* @private
|
||||||
|
* overload 1: components
|
||||||
|
*/
|
||||||
function resolveAsset(
|
function resolveAsset(
|
||||||
type: typeof COMPONENTS,
|
type: typeof COMPONENTS,
|
||||||
name: string,
|
name: string,
|
||||||
@ -44,7 +56,7 @@ function resolveAsset(
|
|||||||
type: typeof DIRECTIVES,
|
type: typeof DIRECTIVES,
|
||||||
name: string
|
name: string
|
||||||
): Directive | undefined
|
): Directive | undefined
|
||||||
|
// implementation
|
||||||
function resolveAsset(
|
function resolveAsset(
|
||||||
type: typeof COMPONENTS | typeof DIRECTIVES,
|
type: typeof COMPONENTS | typeof DIRECTIVES,
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -8,14 +8,14 @@ export let currentScopeId: string | null = null
|
|||||||
const scopeIdStack: string[] = []
|
const scopeIdStack: string[] = []
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function pushScopeId(id: string) {
|
export function pushScopeId(id: string) {
|
||||||
scopeIdStack.push((currentScopeId = id))
|
scopeIdStack.push((currentScopeId = id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function popScopeId() {
|
export function popScopeId() {
|
||||||
scopeIdStack.pop()
|
scopeIdStack.pop()
|
||||||
@ -23,7 +23,7 @@ export function popScopeId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function withScopeId(id: string): <T extends Function>(fn: T) => T {
|
export function withScopeId(id: string): <T extends Function>(fn: T) => T {
|
||||||
return ((fn: Function) =>
|
return ((fn: Function) =>
|
||||||
|
@ -3,7 +3,7 @@ import { warn } from '../warning'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* For prefixing keys in v-on="obj" with "on"
|
* For prefixing keys in v-on="obj" with "on"
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function toHandlers(obj: Record<string, any>): Record<string, any> {
|
export function toHandlers(obj: Record<string, any>): Record<string, any> {
|
||||||
const ret: Record<string, any> = {}
|
const ret: Record<string, any> = {}
|
||||||
|
@ -7,7 +7,7 @@ import { ComponentInternalInstance } from '../component'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a slot function to memoize current rendering instance
|
* Wrap a slot function to memoize current rendering instance
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function withCtx(
|
export function withCtx(
|
||||||
fn: Slot,
|
fn: Slot,
|
||||||
|
@ -229,11 +229,11 @@ export {
|
|||||||
// them in @vue/shared's typings
|
// them in @vue/shared's typings
|
||||||
import { toDisplayString, camelize } from '@vue/shared'
|
import { toDisplayString, camelize } from '@vue/shared'
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
const _toDisplayString = toDisplayString
|
const _toDisplayString = toDisplayString
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
const _camelize = camelize
|
const _camelize = camelize
|
||||||
export { _toDisplayString as toDisplayString, _camelize as camelize }
|
export { _toDisplayString as toDisplayString, _camelize as camelize }
|
||||||
|
@ -161,7 +161,7 @@ let currentBlock: VNode[] | null = null
|
|||||||
* disableTracking is true when creating a v-for fragment block, since a v-for
|
* disableTracking is true when creating a v-for fragment block, since a v-for
|
||||||
* fragment always diffs its children.
|
* fragment always diffs its children.
|
||||||
*
|
*
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function openBlock(disableTracking = false) {
|
export function openBlock(disableTracking = false) {
|
||||||
blockStack.push((currentBlock = disableTracking ? null : []))
|
blockStack.push((currentBlock = disableTracking ? null : []))
|
||||||
@ -187,7 +187,7 @@ let shouldTrack = 1
|
|||||||
* )
|
* )
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function setBlockTracking(value: number) {
|
export function setBlockTracking(value: number) {
|
||||||
shouldTrack += value
|
shouldTrack += value
|
||||||
@ -198,7 +198,7 @@ export function setBlockTracking(value: number) {
|
|||||||
* A block root keeps track of dynamic nodes within the block in the
|
* A block root keeps track of dynamic nodes within the block in the
|
||||||
* `dynamicChildren` array.
|
* `dynamicChildren` array.
|
||||||
*
|
*
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function createBlock(
|
export function createBlock(
|
||||||
type: VNodeTypes | ClassComponent,
|
type: VNodeTypes | ClassComponent,
|
||||||
@ -453,14 +453,14 @@ export function cloneVNode<T, U>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function createTextVNode(text: string = ' ', flag: number = 0): VNode {
|
export function createTextVNode(text: string = ' ', flag: number = 0): VNode {
|
||||||
return createVNode(Text, null, text, flag)
|
return createVNode(Text, null, text, flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function createStaticVNode(
|
export function createStaticVNode(
|
||||||
content: string,
|
content: string,
|
||||||
@ -474,7 +474,7 @@ export function createStaticVNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export function createCommentVNode(
|
export function createCommentVNode(
|
||||||
text: string = '',
|
text: string = '',
|
||||||
|
@ -42,11 +42,7 @@ function trigger(el: HTMLElement, type: string) {
|
|||||||
type ModelDirective<T> = ObjectDirective<T & { _assign: AssignerFn }>
|
type ModelDirective<T> = ObjectDirective<T & { _assign: AssignerFn }>
|
||||||
|
|
||||||
// We are exporting the v-model runtime directly as vnode hooks so that it can
|
// We are exporting the v-model runtime directly as vnode hooks so that it can
|
||||||
// be tree-shaken in case v-model is never used. These are used by compilers
|
// be tree-shaken in case v-model is never used.
|
||||||
// only and userland code should avoid relying on them.
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const vModelText: ModelDirective<
|
export const vModelText: ModelDirective<
|
||||||
HTMLInputElement | HTMLTextAreaElement
|
HTMLInputElement | HTMLTextAreaElement
|
||||||
> = {
|
> = {
|
||||||
@ -96,9 +92,6 @@ export const vModelText: ModelDirective<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
|
export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
|
||||||
beforeMount(el, binding, vnode) {
|
beforeMount(el, binding, vnode) {
|
||||||
setChecked(el, binding, vnode)
|
setChecked(el, binding, vnode)
|
||||||
@ -144,9 +137,6 @@ function setChecked(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const vModelRadio: ModelDirective<HTMLInputElement> = {
|
export const vModelRadio: ModelDirective<HTMLInputElement> = {
|
||||||
beforeMount(el, { value }, vnode) {
|
beforeMount(el, { value }, vnode) {
|
||||||
el.checked = looseEqual(value, vnode.props!.value)
|
el.checked = looseEqual(value, vnode.props!.value)
|
||||||
@ -163,9 +153,6 @@ export const vModelRadio: ModelDirective<HTMLInputElement> = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const vModelSelect: ModelDirective<HTMLSelectElement> = {
|
export const vModelSelect: ModelDirective<HTMLSelectElement> = {
|
||||||
// use mounted & updated because <select> relies on its children <option>s.
|
// use mounted & updated because <select> relies on its children <option>s.
|
||||||
mounted(el, { value }, vnode) {
|
mounted(el, { value }, vnode) {
|
||||||
@ -227,9 +214,6 @@ function getCheckboxValue(
|
|||||||
return key in el ? el[key] : checked
|
return key in el ? el[key] : checked
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const vModelDynamic: ObjectDirective<
|
export const vModelDynamic: ObjectDirective<
|
||||||
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
|
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
|
||||||
> = {
|
> = {
|
||||||
|
@ -23,7 +23,7 @@ const modifierGuards: Record<
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export const withModifiers = (fn: Function, modifiers: string[]) => {
|
export const withModifiers = (fn: Function, modifiers: string[]) => {
|
||||||
return (event: Event, ...args: unknown[]) => {
|
return (event: Event, ...args: unknown[]) => {
|
||||||
@ -48,7 +48,7 @@ const keyNames: Record<string, string | string[]> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @private
|
||||||
*/
|
*/
|
||||||
export const withKeys = (fn: Function, modifiers: string[]) => {
|
export const withKeys = (fn: Function, modifiers: string[]) => {
|
||||||
return (event: KeyboardEvent) => {
|
return (event: KeyboardEvent) => {
|
||||||
|
@ -5,9 +5,6 @@ interface VShowElement extends HTMLElement {
|
|||||||
_vod: string
|
_vod: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const vShow: ObjectDirective<VShowElement> = {
|
export const vShow: ObjectDirective<VShowElement> = {
|
||||||
beforeMount(el, { value }, { transition }) {
|
beforeMount(el, { value }, { transition }) {
|
||||||
el._vod = el.style.display === 'none' ? '' : el.style.display
|
el._vod = el.style.display === 'none' ? '' : el.style.display
|
||||||
|
Loading…
Reference in New Issue
Block a user