Comments (24)
Hey, i am going through the same problem. Any idea when this would be resolved?
from angular-i18next.
@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....
from angular-i18next.
sorry for editing but it is still failing to compile and only when setting strict to false does it work!
@Romanchuk @marcovmun @jemand771
from angular-i18next.
@marcovmun Completely changed build config (custom). Please try:
15.0.3
from angular-i18next.
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.
from angular-i18next.
I have found setting the "skipLibCheck": true
in the tsconfig.json also helps
from angular-i18next.
I have the same problem.
from angular-i18next.
Ok, thanks for report, i'll look for fix along with i18next/i18next#1869
from angular-i18next.
i have similar problem
from angular-i18next.
I endup changing my tsconfig file compilerOptions": { "strict": true, },
but i am still working for dev version, which is not acceptable for prod work
from angular-i18next.
@hamodi @ellyxc @SergejSintschilin @marcovmun Please try [email protected]
from angular-i18next.
I still got compile errors:
node_modules/.pnpm/[email protected]_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/ITranslationService.d.ts:16:105 - error TS2694: Namespace '"D:/projects/libs/ui-components/node_modules/.pnpm/[email protected]
/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/[email protected]_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/[email protected]_vtlaauorlik3d7w2q37gaylcga/node_modules/angular-i18next/lib/I18NextService.d.ts:22:105 - error TS2694: Namespace '"D:/projects/libs/ui-components/node_modules/.pnpm/[email protected]/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/[email protected]_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/[email protected]_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>;
from angular-i18next.
@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
from angular-i18next.
@luisgouveiaaa Do you use pnpm
too?
from angular-i18next.
weirdly enough, I get the same error that's listed in the issue description with version 15.0.0-0
click to expand...
Error: node_modules/angular-i18next/lib/I18NextEvents.d.ts:5:5 - error TS2416: Property 'initialized' in type 'I18NextEvents' is not assignable to the same property in base type 'ITranslationEvents'.
Type 'BehaviorSubject<InitOptions<object>>' is not assignable to type 'BehaviorSubject<InitOptions<object> | undefined>'.
Types of property 'observers' are incompatible.
Type 'Observer<InitOptions<object>>[]' is not assignable to type 'Observer<InitOptions<object> | undefined>[]'.
Type 'Observer<InitOptions<object>>' is not assignable to type 'Observer<InitOptions<object> | undefined>'.
Type 'InitOptions<object> | undefined' is not assignable to type 'InitOptions<object>'.
Type 'undefined' is not assignable to type 'InitOptions<object>'.
5 initialized: BehaviorSubject<i18n.InitOptions<object>>;
~~~~~~~~~~~
Error: node_modules/angular-i18next/lib/I18NextEvents.d.ts:11:5 - error TS2416: Property 'languageChanged' in type 'I18NextEvents' is not assignable to the same property 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>;
~~~~~~~~~~~~~~~
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? 👀
from angular-i18next.
@luisgouveiaaa Do you use
pnpm
too?
No, I'm using regular npm
...
from angular-i18next.
"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.
from angular-i18next.
@marcovmun Thanks, i will apply it to demo app tomorrow. It should help me to localize an issue
from angular-i18next.
@marcovmun What's your i18next version?
from angular-i18next.
@marcovmun Please try to add:
"exclude": ["node_modules"]
from angular-i18next.
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
from angular-i18next.
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 👀
from angular-i18next.
@luisgouveiaaa Do you still need fix for angular v14?
from angular-i18next.
Closing for now
from angular-i18next.
Related Issues (20)
- Is it possible to publish the 15.0 pre-release version to npm? HOT 2
- Interpolation is not working anymore HOT 4
- Property 'initialized' in type 'I18NextEvents' is not assignable to the same property in base type 'ITranslationEvents'. HOT 4
- Is it possible to use this library with Angular Universal and SSR? HOT 4
- New typings prevents passing interpolation to `ITranslationService` HOT 1
- Interpolation Format issues with numbers / dates or i18nextCap HOT 2
- Integration to Angular 16 HOT 9
- angular version issue HOT 1
- Check if there is a translation for the specified key HOT 1
- Update to last i18next version HOT 3
- Mock angular-i18next in Jest HOT 2
- Error when building project in docker HOT 3
- Nesting example HOT 1
- Consider providing a `ng add` schematics HOT 1
- Use Angular i18next in libs with nx workspace
- Typing issue when `returnObjects: true` HOT 2
- Change Language without reloading page HOT 2
- Getting started with Angular v15 HOT 4
- Support i18next v22 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-i18next.