Closed marcovmun closed 1 year ago
I have the same problem.
Ok, thanks for report, i'll look for fix along with https://github.com/i18next/i18next/issues/1869
i have similar problem
Hey, i am going through the same problem. Any idea when this would be resolved?
I endup changing my tsconfig file compilerOptions": { "strict": true, },
but i am still working for dev version, which is not acceptable for prod work
@hamodi @ellyxc @SergejSintschilin @marcovmun Please try angular-i18next@15.0.0-0
@Romanchuk I'm also having this problem but I cannot upgrade to version 15.0.0-0 because its forcing angular version to be 15 and we're still at 14....
I still got compile errors:
node_modules/.pnpm/angular-i18next@15.0.0-0_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/ITranslationService.d.ts:16:105 - error TS2694: Namespace '"D:/projects/libs/ui-components/node_modules/.pnpm/i18next@21.10.0
/node_modules/i18next/index"' has no exported member 'DefaultTFuncReturn'.
16 t(key: string | string[], optionsOrDefault?: string | i18n.TOptions, options?: i18n.TOptions): i18n.DefaultTFuncReturn;
~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/angular-i18next@15.0.0-0_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/I18NextService.d.ts:13:20 - error TS2315: Type 'InitOptions' is not generic.
13 get options(): i18n.InitOptions<object>;
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/angular-i18next@15.0.0-0_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/I18NextService.d.ts:22:105 - error TS2694: Namespace '"D:/projects/libs/ui-components/node_modules/.pnpm/i18next@21.10.0/node
_modules/i18next/index"' has no exported member 'DefaultTFuncReturn'.
22 t(key: string | string[], optionsOrDefault?: string | i18n.TOptions, options?: i18n.TOptions): i18n.DefaultTFuncReturn;
~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/angular-i18next@15.0.0-0_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/I18NextEvents.d.ts:5:34 - error TS2315: Type 'InitOptions' is not generic.
5 initialized: BehaviorSubject<i18n.InitOptions<object>>;
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/angular-i18next@15.0.0-0_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/I18NextEvents.d.ts:11:5 - error TS2416: Property 'languageChanged' in type 'I18NextEvents' is not assignable to the same prop
erty in base type 'ITranslationEvents'.
Type 'BehaviorSubject<string>' is not assignable to type 'BehaviorSubject<string | null>'.
Types of property 'observers' are incompatible.
Type 'Observer<string>[]' is not assignable to type 'Observer<string | null>[]'.
Type 'Observer<string>' is not assignable to type 'Observer<string | null>'.
Type 'string | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.
11 languageChanged: BehaviorSubject<string>;
@marcovmun Please share full contents of yours tsconfig.json
I have "compilerOptions": { "strict": true, },
in this repo for demo app and this error never appears
As i see you are using pnpm and looks like it doesn't get i18n
from i18next/index
@luisgouveiaaa Do you use pnpm
too?
weirdly enough, I get the same error that's listed in the issue description with version 15.0.0-0
if I just do what the error says and edit ITranslationEvents.ts accordingly...
import { BehaviorSubject, Subject } from 'rxjs';
import * as i18n from 'i18next';
export type ResourceEvent = { lng: any; ns: any };
export type MissingKeyEvent = { lngs: any; namespace: any; key: any; res: any };
export interface ITranslationEvents {
- initialized: BehaviorSubject<i18n.InitOptions | undefined>;
+ initialized: BehaviorSubject<i18n.InitOptions>;
loaded: BehaviorSubject<boolean>;
failedLoading: Subject<any>;
missingKey: Subject<MissingKeyEvent>;
added: Subject<ResourceEvent>;
removed: Subject<ResourceEvent>;
- languageChanged: BehaviorSubject<string | null>;
+ languageChanged: BehaviorSubject<string>;
}
... I don't get any errors. I don't know why those are optional as I'm not familiar with any i18next internals whatsoever. I assume just removing the | undefined
and | null
has some unintended side effects
also, I had to upgrade to angular 15 to make the new version of your package work - maybe backport the fix to v14 once you/we figure out how to address this? 👀
@luisgouveiaaa Do you use
pnpm
too?
No, I'm using regular npm
...
"compilerOptions": {
"alwaysStrict": true,
"outDir": "dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"noImplicitThis": true,
"importHelpers": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"target": "es2017",
"module": "es2020",
"lib": [
"es2020",
"dom"
]
},
I have it really strict, but maybe I dit something wrong.
@marcovmun Thanks, i will apply it to demo app tomorrow. It should help me to localize an issue
@marcovmun What's your i18next version?
sorry for editing but it is still failing to compile and only when setting strict to false does it work!
@Romanchuk @marcovmun @jemand771
@marcovmun Please try to add:
"exclude": ["node_modules"]
I've figured out that ng-packagr
removes null and undefined from field defenition... So you got an error.
And this:
export class I18NextEvents implements ITranslationEvents {
initialized = new BehaviorSubject<i18n.InitOptions | undefined>(undefined);
loaded = new BehaviorSubject(false);
failedLoading = new Subject();
missingKey = new Subject<MissingKeyEvent>();
added = new Subject<ResourceEvent>();
removed = new Subject<ResourceEvent>();
languageChanged = new BehaviorSubject<string | null>(null);
}
Becomes this:
export declare class I18NextEvents implements ITranslationEvents {
initialized: BehaviorSubject<i18n.InitOptions<object>>;
loaded: BehaviorSubject<boolean>;
failedLoading: Subject<unknown>;
missingKey: Subject<MissingKeyEvent>;
added: Subject<ResourceEvent>;
removed: Subject<ResourceEvent>;
languageChanged: BehaviorSubject<string>;
}
Obviously if there is a solution - it is in library's tsconfig setup. Trying to find correct setup.. strictNullChecks doesn't help.
Anyway try to exclude 'node_modules' since there is no reason to check typings in 3rd party packages
@marcovmun Completely changed build config (custom). Please try:
15.0.3
type errors are fixed for me from version 15.0.3 onwards, thanks! :D
although I had the same error as other people here, I'd like to wait for someone else to confirm 👀
@luisgouveiaaa Do you still need fix for angular v14?
angular-i18next: 15.0.4 works with i18next 22 on my library, next week we are going to angular v15, so angular v14 is for us not important. Thank you for the fix and support. For me issue can be closed.
I have found setting the "skipLibCheck": true
in the tsconfig.json also helps
Closing for now
Build error when updating to 14.2.0
I think has something to do with: tsconfig.json
"compilerOptions": { "strict": true, },