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

Function isStringTypeExpression

scripts/extractFormFields.ts:38–56  ·  view source on GitHub ↗

* Determines whether a TypeScript expression resolves to a plain string value. * Only string literals and t() calls with a string literal argument are considered * string-typed; anything else (variables, conditionals, JSX elements, other calls) * causes the caller to bail out.

(expr: ts.Expression)

Source from the content-addressed store, hash-verified

36 * causes the caller to bail out.
37 */
38function isStringTypeExpression(expr: ts.Expression): boolean {
39 // 'Name' or "Name"
40 if (ts.isStringLiteral(expr)) {
41 return true;
42 }
43
44 // t('Name') — the i18n translation helper
45 if (
46 ts.isCallExpression(expr) &&
47 ts.isIdentifier(expr.expression) &&
48 expr.expression.text === 't' &&
49 expr.arguments.length > 0 &&
50 ts.isStringLiteral(expr.arguments[0]!)
51 ) {
52 return true;
53 }
54
55 return false;
56}
57
58class FormFieldExtractor {
59 private program: ts.Program;

Callers 2

getJsxTextContentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected