function getTextAndInterpolatedVariables(type, primaryNode, index, babel) {
  throwOnInvalidType(type, primaryNode);
  const componentFoundIndex = index;
  const { text, interpolatedVariableNames } = extractVariableNamesFromQuasiNodes(
    primaryNode,
    babel,
  );
  const { stringOutput, componentFoundIndex: newIndex } = text
    .filter(filterNodes)
    // sort by the order they appear in the source code
    .sort((a, b) => {
      if (a.start > b.start) return 1;
      return -1;
    })
    .reduce(extractNestedTemplatesAndComponents, {
      babel,
      componentFoundIndex,
      stringOutput: [],
      type,
      interpolatedVariableNames,
    });
  return [
    interpolatedVariableNames,
    `{${stringOutput.join('')}}`,
    // return the new component interpolation index
    newIndex,
  ];
}
Retrieve the new text to use, and any interpolated variables

This is used to process tagged template literals like date`${variable}` and number`${num}, ::percent`

for the data example, it will return text of `{variable, date}` with a variable of `variable`
for the number example, it will return text of `{num, number, ::percent}` with a variable of `num`
@param {string} type the name of the tagged template (`date`, `number`, `plural`, etc. - any valid complex ICU type)
@param {TaggedTemplateExpression} primaryNode the template expression node
@param {int} index starting index number of components to be used for interpolations like <0>
@param {*} babel