sveltekit-i18n / lib

Internationalization library built for SvelteKit.
MIT License
491 stars 32 forks source link

TS2353: Object literal may only specify known properties, and '<field>' does not exist in type 'PayloadDefault'. #162

Closed bfontaine closed 9 months ago

bfontaine commented 9 months ago

Hello, I use the latest version (2.4.2) and with TypeScript I get the above error when I use placeholders with t.get:

t.get("common.percentage", { percentage: 42 })

t.get('product.min_max_days', { min: value1, max: value2 })

I don’t have the issue with $t, but the above code is in a .ts file so per the docs I must use t.get.

https://github.com/sveltekit-i18n/lib/issues/69 looks similar, but it was fixed.

I don’t know TypeScript enough to figure out how to fix this.

Any idea?

Benjababe commented 9 months ago

Updating the config by putting the placeholder names in the triangle brackets like here did the trick for me

https://github.com/sveltekit-i18n/lib/blob/c2d6f5395682e08533e5903f25289b3e9b179325/examples/parser-default/src/lib/translations/index.ts#L10-L15