( ast: MessageFormatElement[] )
| 140 | * @param ast AST |
| 141 | */ |
| 142 | export function hoistSelectors( |
| 143 | ast: MessageFormatElement[] |
| 144 | ): MessageFormatElement[] { |
| 145 | for (let i = 0; i < ast.length; i++) { |
| 146 | const el = ast[i] |
| 147 | if (isPluralOrSelectElement(el)) { |
| 148 | return [hoistPluralOrSelectElement(ast, el, i)] |
| 149 | } |
| 150 | if (isTagElement(el) && findPluralOrSelectElement([el])) { |
| 151 | throw new Error( |
| 152 | 'Cannot hoist plural/select within a tag element. Please put the tag element inside each plural/select option' |
| 153 | ) |
| 154 | } |
| 155 | } |
| 156 | return ast |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Collect all variables in an AST to Record<string, TYPE> |
no test coverage detected