-
-
Notifications
You must be signed in to change notification settings - Fork 20
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript: 'I18n' can only be imported by using a default import #89
Comments
I have a similar problem: |
What does your tsconfig.json file look like? I have a project running with 4.4.0 and it's working with $ yarn why i18n-js
└─ app@workspace:.
└─ i18n-js@npm:4.4.0 (via npm:^4.4.0)
$ cat app/assets/scripts/config/i18n.ts
import { I18n as I18nJS } from "i18n-js";
import translations from "config/translations.json";
export const i18n = new I18nJS(translations);
i18n.defaultLocale = "en";
$ tsc --noEmit
$ echo $?
0 Here's mine: {
"include": ["./app/assets/scripts"],
"compilerOptions": {
"rootDir": ".",
"baseUrl": "./app/assets/scripts",
"lib": ["DOM", "es2020"],
"target": "es2015",
"moduleResolution": "node",
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true,
},
} |
I made a PR to fix the issue |
@TheWirv based on your PR, looks like you don't have |
OK, it makes to define the whole path then. |
Also, the |
@TheWirv just made a change on your pr. Can you please double check that everything still works? |
Yep, works perfectly fine still 👌🏼 |
Just released v4.4.1 with the fix for this issue. Thank you all for the fast turnaround. :) |
Thank you too for the fast review and merge! :) |
Description
Importing as
import { I18n } from 'i18n-js';
throws TS error'I18n' can only be imported by using a default import
. Importing as default importimport I18n from 'i18n-js';
throws on new I18n()This expression is not constructable. Type 'typeof I18n' has no construct signatures.
How to reproduce
Use I18n as described in docs
What do you expect
Not to throws Typescript error
Software:
The text was updated successfully, but these errors were encountered: