feat(compiler): transform component slots
This commit is contained in:
@@ -27,7 +27,8 @@ export const enum NodeTypes {
|
||||
JS_CALL_EXPRESSION,
|
||||
JS_OBJECT_EXPRESSION,
|
||||
JS_PROPERTY,
|
||||
JS_ARRAY_EXPRESSION
|
||||
JS_ARRAY_EXPRESSION,
|
||||
JS_SLOT_FUNCTION
|
||||
}
|
||||
|
||||
export const enum ElementTypes {
|
||||
@@ -157,6 +158,7 @@ export type JSChildNode =
|
||||
| ObjectExpression
|
||||
| ArrayExpression
|
||||
| ExpressionNode
|
||||
| SlotFunctionExpression
|
||||
|
||||
export interface CallExpression extends Node {
|
||||
type: NodeTypes.JS_CALL_EXPRESSION
|
||||
@@ -180,6 +182,12 @@ export interface ArrayExpression extends Node {
|
||||
elements: Array<string | JSChildNode>
|
||||
}
|
||||
|
||||
export interface SlotFunctionExpression extends Node {
|
||||
type: NodeTypes.JS_SLOT_FUNCTION
|
||||
params: ExpressionNode | undefined
|
||||
returns: ChildNode[]
|
||||
}
|
||||
|
||||
export function createArrayExpression(
|
||||
elements: ArrayExpression['elements'],
|
||||
loc: SourceLocation
|
||||
@@ -264,3 +272,16 @@ export function createCallExpression(
|
||||
arguments: args
|
||||
}
|
||||
}
|
||||
|
||||
export function createFunctionExpression(
|
||||
params: ExpressionNode | undefined,
|
||||
returns: ChildNode[],
|
||||
loc: SourceLocation
|
||||
): SlotFunctionExpression {
|
||||
return {
|
||||
type: NodeTypes.JS_SLOT_FUNCTION,
|
||||
params,
|
||||
returns,
|
||||
loc
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user