MCPcopy Index your code
hub / github.com/formatjs/formatjs / isSingularMessageDecl

Function isSingularMessageDecl

packages/ts-transformer/transform.ts:223–251  ·  view source on GitHub ↗
(
  ts: TypeScript,
  node:
    | typescript.CallExpression
    | typescript.JsxOpeningElement
    | typescript.JsxSelfClosingElement,
  additionalComponentNames: string[]
)

Source from the content-addressed store, hash-verified

221}
222
223function isSingularMessageDecl(
224 ts: TypeScript,
225 node:
226 | typescript.CallExpression
227 | typescript.JsxOpeningElement
228 | typescript.JsxSelfClosingElement,
229 additionalComponentNames: string[]
230) {
231 const compNames = new Set([
232 'FormattedMessage',
233 'defineMessage',
234 'formatMessage',
235 '$formatMessage',
236 '$t',
237 ...additionalComponentNames,
238 ])
239 let fnName = ''
240 if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
241 fnName = node.expression.text
242 } else if (ts.isJsxOpeningElement(node) && ts.isIdentifier(node.tagName)) {
243 fnName = node.tagName.text
244 } else if (
245 ts.isJsxSelfClosingElement(node) &&
246 ts.isIdentifier(node.tagName)
247 ) {
248 fnName = node.tagName.text
249 }
250 return compNames.has(fnName)
251}
252
253function evaluateStringConcat(
254 ts: TypeScript,

Calls

no outgoing calls

Tested by

no test coverage detected