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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 19.8.5 causes TypeError: object.hasOwnProperty is not a function #1542

Closed
hixus opened this issue Feb 1, 2021 · 5 comments 路 Fixed by razee-io/Razeedash-api#823
Closed

Comments

@hixus
Copy link

hixus commented Feb 1, 2021

馃挜 Regression Report

version 19.8.5 causes TypeError: object.hasOwnProperty is not a function when calling t-function.

Last working version

Worked up to version: 19.8.4

Stopped working in version: 19.8.5

To Reproduce

This is my config which works with old version.

import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import * as dev from "../locales/dev.json";
import * as fi from "../locales/fi.json";

i18n
  .use(initReactI18next) 
  .init({
    resources: { fi, dev },
    lng: "fi",
    ns: ["default"], 
    defaultNS: "default",
    debug: true,
    keySeparator: false,
    interpolation: {
      escapeValue: false, 
    },
  });

export default i18n;

Expected behavior

T-function should work without throwing.

i18n.t('hello') // should not throw TypeError: object.hasOwnProperty is not a function 

Your Environment

  • runtime version: i.e. node v14
  • i18next version: i.e. 19.8.5 (react-i18next 11.8.5)
  • os: Mac
@adrai
Copy link
Member

adrai commented Feb 1, 2021

Not able to reproduce it.
Can you create a reproducable example? Maybe directly on codesandbox?

@AdirAmsalem
Copy link

AdirAmsalem commented Feb 2, 2021

@adrai I saw you pushed a fix (thanks!) but our app still breaks with the new version.
Any chance it wasn't fully fixed? (the code attached uses i18next-react too)
image

@adrai
Copy link
Member

adrai commented Feb 2, 2021

@AdirAmsalem still waiting to be able to reproduce your issue...

@AdirAmsalem
Copy link

AdirAmsalem commented Feb 2, 2021

@adrai for us (I'm not with @hixus so maybe his issue is different) it fails specifically in tests, with the following configuration:
https://codesandbox.io/s/cool-noyce-xl9f3?file=/src/App.js

You can see that with i18next@19.8.4 it works, but if you'll change it to i18next@19.8.6 it'll fail.

I suspect it's related to the usage of Proxy here:

i18n.init({
  resources: new Proxy({}, { get: (_target, name) => name })
});

We do it for something in our tests that with a corresponding postProcessor allows us to validate the output in a customized way (for t(key, options)).

Btw, I know there's cimode which is similar, but this one allows us to do something more advanced which also includes the options etc.

Hope this helps, and thanks for your time!

@adrai adrai closed this as completed in 75c6294 Feb 2, 2021
@adrai
Copy link
Member

adrai commented Feb 2, 2021

Should be fixed with v19.8.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment