MCPcopy
hub / github.com/formatjs/formatjs / getMessageDescriptorValue

Function getMessageDescriptorValue

packages/babel-plugin-formatjs/utils.ts:43–65  ·  view source on GitHub ↗
(
  path?:
    | NodePath<t.StringLiteral>
    | NodePath<t.JSXExpressionContainer>
    | NodePath<t.TemplateLiteral>,
  isMessageNode?: boolean
)

Source from the content-addressed store, hash-verified

41}
42
43function getMessageDescriptorValue(
44 path?:
45 | NodePath<t.StringLiteral>
46 | NodePath<t.JSXExpressionContainer>
47 | NodePath<t.TemplateLiteral>,
48 isMessageNode?: boolean
49) {
50 if (!path) {
51 return ''
52 }
53 if (path.isJSXExpressionContainer()) {
54 // If this is already compiled, no need to recompiled it
55 if (isMessageNode && path.get('expression').isArrayExpression()) {
56 return ''
57 }
58 path = path.get('expression') as NodePath<t.StringLiteral>
59 }
60
61 // Always trim the Message Descriptor values.
62 const descriptorValue = evaluatePath(path)
63
64 return descriptorValue
65}
66
67export function createMessageDescriptor(
68 propPaths: [

Callers 2

getICUMessageValueFunction · 0.85

Calls 2

evaluatePathFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected