question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Erorr: f is not a function

See original GitHub issue

After I upgraded to 0.8.6 from 0.8.3 I started getting the error “” in one of my mocha tests. I stepped in with the debugger and i noticed that f get’s compiled as an object and not as a function in i18n.__ = function i18nTranslate(phrase) {.

image

This particular key is an object, which in the past I was able to translate as an object and iterate over the translated strings.

  "roles": {
    "role1": "role1 name",
    "role2": "role2 name"
  }

My setup does enable object notation:

i18n.configure({
  directory: `${__dirname}/../../shared/locales`,
  objectNotation: true,
  updateFiles: false,
  defaultLocale: 'en',
  api: {
    __mf: 'translate',
    getLocale: 'locale'
  }
});

Is there a breaking change I am missing?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mashpiecommented, Mar 29, 2020

There has been a major version upgrade on messageformat in release 0.8.4 which also required a compatibility setting to keep passing my tests:

    // now head over to Messageformat
    // and try to cache instance
    if (MessageformatInstanceForLocale[targetLocale]) {
      mf = MessageformatInstanceForLocale[targetLocale];
    } else {
      mf = new Messageformat(targetLocale);

      // @see https://messageformat.github.io/messageformat/MessageFormat#disablePluralKeyChecks__anchor
      mf.disablePluralKeyChecks();
      mf.compiledFunctions = {};
      MessageformatInstanceForLocale[targetLocale] = mf;
    }

    // let's try to cache that function

to be honest I can’t tell wether the older messageformat compiled to functions or objects as I never tested on types but on results (https://github.com/mashpie/i18n-node/blob/master/test/i18n.mf.js)

0reactions
mashpiecommented, Aug 18, 2020

well… this is good news. Could be that any of an npm update or yarn update is failing pulling newest version. A common solution is to cleanUp node_modules and/or yarn cache clean

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why "TypeError: f is not a function"? - Stack Overflow
It calls the just-declared function, which then calls f , but f has not been initialized yet and thus is not a function....
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
Uncaught TypeError: f is not a function · Issue #1 - GitHub
fromFSAtoCCA, i get the error as described in the title. This does not seem to fix the problem after upgrading to redux 3.0.0....
Read more >
How to solve the "is not a function" error in JavaScript
It consider require('fs') as the name of the function, which is something that could actually work if the module export returned a function....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found