cospired / i18n-iso-languages

i18n for ISO 639-1 language codes
MIT License
49 stars 29 forks source link

TypeError: Cannot read property 'toAlpha3T' of undefined #41

Closed bropat closed 2 years ago

bropat commented 2 years ago

Here is a quick test case:

mkdir testcase
cd testcase

git init
npm init --y

npm i --save-prod @cospired/i18n-iso-languages
npm i -g typescript

mkdir src
cd src

Create the file testcase.tswith following content:

import { isValid as isValidLanguageCode } from "@cospired/i18n-iso-languages"

console.log(`isValidLanguageCode: ${isValidLanguageCode("en")}`);

Compile and execute it:

tsc testcase.ts

node testcase.js

D:\Projects\private\testcase\node_modules\@cospired\i18n-iso-languages\index.js:265
  return this.toAlpha3T(code) !== undefined;
              ^

TypeError: Cannot read property 'toAlpha3T' of undefined
    at exports.isValid (D:\Projects\private\testcase\node_modules\@cospired\i18n-iso-languages\index.js:265:15)
    at Object.<anonymous> (D:\Projects\private\testcase\src\testcase.js:4:72)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

If I remove the this. above, it will work.

bropat commented 2 years ago

@e110c0 Let me know if you need something else.

bropat commented 2 years ago

@e110c0 Can you tell me approximately when you will release the fix? I have 2 projects that depend on it, where I can't publish the new version at the moment.

Thank you!

e110c0 commented 2 years ago

fixed in v3.1.1