MCPcopy
hub / github.com/formatjs/formatjs / createMessageDescriptor

Function createMessageDescriptor

packages/babel-plugin-formatjs/utils.ts:67–91  ·  view source on GitHub ↗
(
  propPaths: [
    NodePath<t.JSXIdentifier> | NodePath<t.Identifier>,
    NodePath<t.StringLiteral> | NodePath<t.JSXExpressionContainer>,
  ][]
)

Source from the content-addressed store, hash-verified

65}
66
67export function createMessageDescriptor(
68 propPaths: [
69 NodePath<t.JSXIdentifier> | NodePath<t.Identifier>,
70 NodePath<t.StringLiteral> | NodePath<t.JSXExpressionContainer>,
71 ][]
72): MessageDescriptorPath {
73 return propPaths.reduce(
74 (hash: MessageDescriptorPath, [keyPath, valuePath]) => {
75 const key = getMessageDescriptorKey(
76 keyPath
77 ) as keyof MessageDescriptorPath
78
79 if (DESCRIPTOR_PROPS.has(key)) {
80 hash[key] = valuePath
81 }
82
83 return hash
84 },
85 {
86 id: undefined,
87 defaultMessage: undefined,
88 description: undefined,
89 }
90 )
91}
92
93export function evaluateMessageDescriptor(
94 descriptorPath: MessageDescriptorPath,

Callers 2

visitorFunction · 0.90
processMessageObjectFunction · 0.90

Calls 1

getMessageDescriptorKeyFunction · 0.85

Tested by

no test coverage detected