Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation breaks with translation key called name #170

Closed
nachtjasmin opened this issue Feb 10, 2022 · 3 comments
Closed

Translation breaks with translation key called name #170

nachtjasmin opened this issue Feb 10, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@nachtjasmin
Copy link

nachtjasmin commented Feb 10, 2022

Version

4.0.0

Describe the bug

When using a key in the translation called name, the whole object breaks and cannot be loaded anymore. Example translation:

import type { BaseTranslation } from "typesafe-i18n";

const en: BaseTranslation = {
  working: { title: "it works!" },
  notWorking: {
    title: "not working",
    name: "repro", // remove this line, and everything works again
  },
};

export default en;

Other parts of the translation (working in the example case) are not affected by this.

Reproduction

Repository for repro can be found here:
https://github.com/chloe-the-catgirl/typesafe-i18n-repro

The index page works, the "/test" page breaks.

Logs

Cannot assign to read only property 'name' of function '()=>""'
TypeError: Cannot assign to read only property 'name' of function '()=>""'
    at Function.assign (<anonymous>)
    at L (/home/jasmin/repos/typesafe-i18n-repro/node_modules/.pnpm/typesafe-i18n@4.0.0_typescript@4.5.5/node_modules/typesafe-i18n/adapters/adapter-svelte.cjs:1:2572)
    at b (/home/jasmin/repos/typesafe-i18n-repro/node_modules/.pnpm/typesafe-i18n@4.0.0_typescript@4.5.5/node_modules/typesafe-i18n/adapters/adapter-svelte.cjs:1:2608)
    at Object.get (/home/jasmin/repos/typesafe-i18n-repro/node_modules/.pnpm/typesafe-i18n@4.0.0_typescript@4.5.5/node_modules/typesafe-i18n/adapters/adapter-svelte.cjs:1:2705)
    at test.svelte:6:18
    at Object.$$render (/home/jasmin/repos/typesafe-i18n-repro/node_modules/.pnpm/svelte@3.46.4/node_modules/svelte/internal/index.js:1745:22)
    at Object.default (root.svelte:43:47)
    at eval (/src/routes/__layout.svelte:23:47)
    at Object.$$render (/home/jasmin/repos/typesafe-i18n-repro/node_modules/.pnpm/svelte@3.46.4/node_modules/svelte/internal/index.js:1745:22)
    at root.svelte:37:45

Config

{
  "$schema": "https://unpkg.com/typesafe-i18n@4.0.0/schema/typesafe-i18n.json",
  "adapter": "svelte"
}

Additional information

No response

@nachtjasmin nachtjasmin added the bug Something isn't working label Feb 10, 2022
@ivanhofer
Copy link
Owner

@chloe-the-catgirl thanks for opening this issue.
Was it working in a previous version? Or are you a first time version 4.x.x user?
I'll take a deeper look at this issue in the next couple of days

@nachtjasmin
Copy link
Author

It was working in a 2.x version, I know that for sure. Not sure which one exactly, but it worked.

@ivanhofer
Copy link
Owner

@chloe-the-catgirl thanks!

I was able to find and fix the issue. I just released version 4.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants