🐛 Bug Report
When using the t function (enableSelector: true) with both returnObjects: true and a context option, the inferred return type is incorrect.
Problem 1: Array object types are incorrectly narrowed
Given a translation key that resolves to an array of objects, the returned type loses properties. Instead of inferring the full object shape, it produces a union of partial types. (src/App.tsx#16)
Problem 2: Valid translation keys with context produce a TS error (maybe not a bug and intended behavior but wanted to report anyway)
Using the context option with a valid translation key causes a TypeScript error, even though the key and context combination is valid at runtime. (src/App.tsx#29)
To Reproduce
https://codesandbox.io/p/devbox/w5qphh (wanted to do a sandbox but TS has a issue there so its a codebox)
Expected behavior
Problem 1. I expect that the return type narrows to
({
transKey1: string;
transKey2: string;
})[]
Problem 2. No TS error
Your Environment
- runtime version: node 22 and node 20
- i18next version: 25.8.13
- os: Mac 15.7.4
- TypeScript version: 5.9.3 and 5.8.3
🐛 Bug Report
When using the
tfunction (enableSelector: true) with bothreturnObjects: trueand acontextoption, the inferred return type is incorrect.Problem 1: Array object types are incorrectly narrowed
Given a translation key that resolves to an array of objects, the returned type loses properties. Instead of inferring the full object shape, it produces a union of partial types. (
src/App.tsx#16)Problem 2: Valid translation keys with context produce a TS error (maybe not a bug and intended behavior but wanted to report anyway)
Using the context option with a valid translation key causes a TypeScript error, even though the key and context combination is valid at runtime. (
src/App.tsx#29)To Reproduce
https://codesandbox.io/p/devbox/w5qphh (wanted to do a sandbox but TS has a issue there so its a codebox)
Expected behavior
Problem 1. I expect that the return type narrows to
Problem 2. No TS error
Your Environment