robisim74/qwik-speak

Production build is referencing non existent variable when using typescript optional

juanpmarin opened this issue · 2 comments

Hi!
I'm using a translation like this one:

      {t("test.translation@@Envío para {{recipient}}", {
        recipient: remoteData.value.embed?.foo,
      })}

When I use the optional operator ?, translation fails when ran on client side, as compiled code is referencing a non existing variable, for example:

      {t("test.translation@@Envío para {{recipient}}", {
        recipient: remoteData.value.embed?.foo,
      })}

Compiles to:

import { N as o } from "./q-767952c7.js";
import "./q-3c25f3f0.js";
import { useRemoteData as r } from "./q-c4196f84.js";
import "./q-4012d65d.js";
const p = () => {
  var t;
  const e = r();
  return o("div", null, null, `Envío para ${te.value.embed}`, 1, "sB_0");
};
export { p as s_BP0CpRo5x74 };

As you can see, te does not exists

On the other side:

      {t("test.translation@@Envío para {{recipient}}", {
        recipient: remoteData.value.embed.foo,
      })}

Compiles to:

import { N as e } from "./q-767952c7.js";
import "./q-3c25f3f0.js";
import { useRemoteData as o } from "./q-d79a8c36.js";
import "./q-c200c11c.js";
const m = () => {
  const t = o();
  return e("div", null, null, `Envío para ${t.value.embed.foo}`, 1, "sB_0");
};
export { m as s_BP0CpRo5x74 };

You can find code to reproduce the error here:
https://github.com/juanpmarin/qwik-speak-repro/blob/4298ba760b2b05bc4852a6cf21fa7e0b0e8b9646/src/routes/test/%5Bid%5D/index.tsx#L17-L21

Thanks!