MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getJsxNodeKind

Method getJsxNodeKind

compiler/companion/src/JSXProcessor.ts:761–789  ·  view source on GitHub ↗
(tag: ts.JsxTagNameExpression, nodeTypeStr: string, output: JSXOutputState)

Source from the content-addressed store, hash-verified

759 }
760
761 private getJsxNodeKind(tag: ts.JsxTagNameExpression, nodeTypeStr: string, output: JSXOutputState): JSXNodeKind {
762 if (ts.isIdentifier(tag)) {
763 const isIntrinsic = nodeTypeStr[0].toLowerCase() === nodeTypeStr[0];
764 if (isIntrinsic) {
765 if (nodeTypeStr === 'slot') {
766 return JSXNodeKind.slot;
767 } else {
768 if (nodeTypeStr === 'slotted') {
769 this.onError(tag, '"slotted" elements must be direct children of components');
770 }
771 return JSXNodeKind.element;
772 }
773 }
774 }
775
776 if (tag.kind === ts.SyntaxKind.JsxNamespacedName) {
777 this.onError(tag, 'JSX Namespaced Names are not supported');
778 }
779
780 const resolvedType = resolveTypeOfExpression(tag, output.typeChecker);
781
782 const symbol = resolvedType.effectiveObjectInfo?.symbol;
783 if ((symbol && symbol.flags & ts.SymbolFlags.Function) || resolvedType.effectiveType === SymbolType.function) {
784 return JSXNodeKind.functionComponent;
785 }
786
787 // Consider any expressions as constructors
788 return JSXNodeKind.component;
789 }
790
791 private outputJSXElement(
792 jsxElement: JSXElement,

Callers 1

outputJSXMethod · 0.95

Calls 3

onErrorMethod · 0.95
resolveTypeOfExpressionFunction · 0.90
isIdentifierMethod · 0.80

Tested by

no test coverage detected