MCPcopy Index your code
hub / github.com/getsentry/sentry / getJsxTextContent

Method getJsxTextContent

scripts/extractFormFields.ts:280–307  ·  view source on GitHub ↗

* Extract text content from JSX element children as expression (for Meta.Label, Meta.HintText) * Returns the expression text as-is, preserving t() calls

(
    node: ts.JsxElement | ts.JsxSelfClosingElement,
    sourceFile: ts.SourceFile
  )

Source from the content-addressed store, hash-verified

278 * Returns the expression text as-is, preserving t() calls
279 */
280 private getJsxTextContent(
281 node: ts.JsxElement | ts.JsxSelfClosingElement,
282 sourceFile: ts.SourceFile
283 ): string | null {
284 if (ts.isJsxSelfClosingElement(node)) {
285 return null;
286 }
287
288 for (const child of node.children) {
289 // Direct text: <Meta.Label>Name</Meta.Label>
290 if (ts.isJsxText(child)) {
291 const text = child.text.trim();
292 if (text) {
293 return `"${text}"`;
294 }
295 }
296 // Expression: <Meta.Label>{t('Name')}</Meta.Label> -> t('Name')
297 if (ts.isJsxExpression(child) && child.expression) {
298 const expr = child.expression;
299 if (!isStringTypeExpression(expr)) {
300 return null;
301 }
302 return expr.getText(sourceFile);
303 }
304 }
305
306 return null;
307 }
308
309 private getJsxTagName(
310 node: ts.JsxElement | ts.JsxSelfClosingElement,

Callers 1

visitMethod · 0.95

Calls 2

isStringTypeExpressionFunction · 0.85
trimMethod · 0.80

Tested by

no test coverage detected