QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.19k stars 52 forks source link

[Question] How to test properly that a deep path exists or not in a type unsafe context? #336

Open gustaveWPM opened 5 months ago

gustaveWPM commented 5 months ago

Hello! Let's assume I have, sometimes (very rarely), type unsafe calls to the t function.

I would like to know what is the proper way to detect if t('something.invalid') doesn't exist.

I've done it in a way that satisfies me, by directly inspecting my i18n object with Object.keys, and then checking with includes whether the key I'm looking for actually exists, but I'd like to know if this is the right choice?

Thank you in advance for your answers!