(
node: ts.Node,
children: ts.JsxChild[],
slotName: ts.Expression | undefined,
output: JSXOutputState,
transformContext: ts.TransformationContext,
)
| 439 | } |
| 440 | |
| 441 | private outputSlot( |
| 442 | node: ts.Node, |
| 443 | children: ts.JsxChild[], |
| 444 | slotName: ts.Expression | undefined, |
| 445 | output: JSXOutputState, |
| 446 | transformContext: ts.TransformationContext, |
| 447 | ): ts.Statement[] { |
| 448 | const childrenWithoutTexts = children.filter( |
| 449 | (child) => !(this.isEmptyJsxExpression(child) || this.isJsxText(child)), |
| 450 | ); |
| 451 | const singleExpr = this.getSingleJsxExpression(childrenWithoutTexts); |
| 452 | |
| 453 | if (singleExpr && this.isNamedSlotsExpression(singleExpr)) { |
| 454 | return this.outputNamedSlotsExpression(singleExpr, singleExpr.arguments, output, transformContext); |
| 455 | } else if (singleExpr && this.isUnnamedSlotsExpression(singleExpr)) { |
| 456 | return [this.outputSlotExpression(singleExpr, singleExpr.arguments, output, transformContext)]; |
| 457 | } else { |
| 458 | const innerStatements = this.outputJSXChildren(node, childrenWithoutTexts, output, transformContext); |
| 459 | const lambdaInner = transformContext.factory.createArrowFunction( |
| 460 | undefined, |
| 461 | undefined, |
| 462 | [], |
| 463 | undefined, |
| 464 | undefined, |
| 465 | this.toBlock(innerStatements, transformContext), |
| 466 | ); |
| 467 | |
| 468 | if (slotName) { |
| 469 | return [this.createRendererCall('setNamedSlot', [slotName, lambdaInner], undefined, transformContext)]; |
| 470 | } else { |
| 471 | return [this.createRendererCall('setUnnamedSlot', [lambdaInner], undefined, transformContext)]; |
| 472 | } |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | private createConstVariable( |
| 477 | variableName: string, |
no test coverage detected