Git Product home page Git Product logo

Comments (24)

hamodi avatar hamodi commented on June 25, 2024 1

Hey, i am going through the same problem. Any idea when this would be resolved?

from angular-i18next.

luisgouveiaaa avatar luisgouveiaaa commented on June 25, 2024 1

@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.

hamodi avatar hamodi commented on June 25, 2024 1

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.

Romanchuk avatar Romanchuk commented on June 25, 2024 1

@marcovmun Completely changed build config (custom). Please try:
15.0.3

from angular-i18next.

marcovmun avatar marcovmun commented on June 25, 2024 1

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.

aamcatamney avatar aamcatamney commented on June 25, 2024 1

I have found setting the "skipLibCheck": true in the tsconfig.json also helps

from angular-i18next.

SergejSintschilin avatar SergejSintschilin commented on June 25, 2024

I have the same problem.

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 25, 2024

Ok, thanks for report, i'll look for fix along with i18next/i18next#1869

from angular-i18next.

ellyxc avatar ellyxc commented on June 25, 2024

i have similar problem

from angular-i18next.

ellyxc avatar ellyxc commented on June 25, 2024

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.

Romanchuk avatar Romanchuk commented on June 25, 2024

@hamodi @ellyxc @SergejSintschilin @marcovmun Please try [email protected]

from angular-i18next.

marcovmun avatar marcovmun commented on June 25, 2024

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.

Romanchuk avatar Romanchuk commented on June 25, 2024

@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.

Romanchuk avatar Romanchuk commented on June 25, 2024

@luisgouveiaaa Do you use pnpm too?

from angular-i18next.

jemand771 avatar jemand771 commented on June 25, 2024

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 avatar luisgouveiaaa commented on June 25, 2024

@luisgouveiaaa Do you use pnpm too?

No, I'm using regular npm...

from angular-i18next.

marcovmun avatar marcovmun commented on June 25, 2024
 "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.

Romanchuk avatar Romanchuk commented on June 25, 2024

@marcovmun Thanks, i will apply it to demo app tomorrow. It should help me to localize an issue

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 25, 2024

@marcovmun What's your i18next version?

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 25, 2024

@marcovmun Please try to add:
"exclude": ["node_modules"]

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 25, 2024

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.

jemand771 avatar jemand771 commented on June 25, 2024

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.

Romanchuk avatar Romanchuk commented on June 25, 2024

@luisgouveiaaa Do you still need fix for angular v14?

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 25, 2024

Closing for now

from angular-i18next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.