import { ElementNode, ObjectExpression, createObjectExpression, NodeTypes, createCompoundExpression, createCallExpression, CompoundExpressionNode, CallExpression, createObjectProperty, createSimpleExpression, createFunctionExpression, DirectiveNode, ElementTypes, ExpressionNode, Property, ChildNode, SourceLocation } from '../ast' import { TransformContext } from '../transform' import { buildProps } from './transformElement' import { createCompilerError, ErrorCodes } from '../errors' import { isSimpleIdentifier } from '../utils' import { RENDER_SLOT } from '../runtimeConstants' import { isString } from '@vue/shared' const isVSlot = (p: ElementNode['props'][0]): p is DirectiveNode => p.type === NodeTypes.DIRECTIVE && p.name === 'slot' export function buildSlots( { props, children, loc }: ElementNode, context: TransformContext ): ObjectExpression { const slots: Property[] = [] // 1. Check for default slot with slotProps on component itself. // const explicitDefaultSlot = props.find(isVSlot) if (explicitDefaultSlot) { const { arg, exp, loc } = explicitDefaultSlot if (arg) { context.onError( createCompilerError(ErrorCodes.X_NAMED_SLOT_ON_COMPONENT, loc) ) } slots.push(buildSlot(`default`, exp, children, loc)) } // 2. Iterate through children and check for template slots //