Closed parth391 closed 1 year ago
I'm not sure why but in the interface the return type is optional. \ https://github.com/EugeneMeles/laravel-react-i18n/blob/c92cbf4a0bb45fa8cb577f9ee4211202754ef50e/src/interfaces/context.ts#L4
Therefore Typescript is throwing the error Cannot invoke an object which is possibly 'undefined' \ Using the following snippet will bypass this error.
Cannot invoke an object which is possibly 'undefined'
t?.('translation')
It seems like the trans function that's called when using t can't return an optional value and is always string. https://github.com/EugeneMeles/laravel-react-i18n/blob/c92cbf4a0bb45fa8cb577f9ee4211202754ef50e/src/provider.ts#L121
trans
t
string
Fixed at latest(2.0.0) version
I'm not sure why but in the interface the return type is optional. \ https://github.com/EugeneMeles/laravel-react-i18n/blob/c92cbf4a0bb45fa8cb577f9ee4211202754ef50e/src/interfaces/context.ts#L4
Therefore Typescript is throwing the error
Cannot invoke an object which is possibly 'undefined'
\ Using the following snippet will bypass this error.It seems like the
trans
function that's called when usingt
can't return an optional value and is alwaysstring
. https://github.com/EugeneMeles/laravel-react-i18n/blob/c92cbf4a0bb45fa8cb577f9ee4211202754ef50e/src/provider.ts#L121