Skip to content

Cannot find module './evaluation-context' or its corresponding type declarations. #283

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

Closed
ramtinsoltani opened this issue Jan 17, 2025 · 6 comments · Fixed by #286
Closed
Assignees

Comments

@ramtinsoltani
Copy link

I'm trying to setup Flagsmith in my Angular project and I cannot get the project compiled after installing flagsmith package from NPM and initializing it like below after following the documentation:

import { Injectable } from '@angular/core';
import flagsmith from 'flagsmith';
import { IFlags, IRetrieveInfo, LoadingState } from 'flagsmith/types';
import { environment } from 'src/environments/environment';

@Injectable({
  providedIn: 'root'
})
export class FlagsmithService {

  constructor() { }

  public init(): void {

    flagsmith.init({
      environmentID: environment.FLAGSMITH_ENV_ID,
      api: environment.FLAGSMITH_API,
      cacheFlags: true,
      enableAnalytics: true,
      onChange: this.onChange.bind(this)
    });

  }

  private onChange(oldFlags: IFlags<string> | null, params: IRetrieveInfo, loadingState: LoadingState): void {

    // ...

  }

}

The error is:

Error: node_modules/flagsmith/types.d.ts:1:86 - error TS2307: Cannot find module './evaluation-context' or its corresponding type declarations.

1 import { EvaluationContext, IdentityEvaluationContext, TraitEvaluationContext } from "./evaluation-context";

I can't find evaluation-context.ts in the installed package, but I see it in this repository. This is the documentation I have followed: https://docs.flagsmith.com/clients/javascript

Any idea why I'm getting this error and why this file is missing from the NPM package? I have tried the latest version as well as v8.* to no avail.

I'm also a bit confused about the documentation as the NPM package has marked environmentID in IInitConfig interface deprecated (@deprecated — Please consider using evaluationContext.identity: IInitConfig.evaluationContext.) while I can't find anything in the documentation about this.

@matthewelwell
Copy link
Contributor

Hi @ramtinsoltani , can you please confirm which version of the client you are using?

@tiagoapolo
Copy link
Contributor

@ramtinsoltani
Copy link
Author

@tiagoapolo @matthewelwell I just updated to the latest version 9.0.1 (was using 9.0.0 previously) and the problem is still there when running the application using ng serve or building it with ng build --aot:

Error: node_modules/flagsmith/types.d.ts:1:86 - error TS2307: Cannot find module './evaluation-context' or its corresponding type declarations.

1 import { EvaluationContext, IdentityEvaluationContext, TraitEvaluationContext } from "./evaluation-context";

I'm using npm install flagsmith (installed "flagsmith": "^9.0.1", in package.json) with Angular 18.2 and TypeScript 5.5.4

@matthewelwell matthewelwell reopened this Jan 21, 2025
@kyle-ssg
Copy link
Member

kyle-ssg commented Jan 21, 2025

Hi @ramtinsoltani although I cannot replicate this in an angular project, I can see why it would occur. Also you are correct to question the evaluation context - we've un-deprecated its predecessors whilst we document it further.

If you're able, could you confirm that flagsmith@9.0.2-beta.1 resolves your issue? This version will also un-deprecate the fields mentioned as they were missed in our previous build.

Thanks

@ramtinsoltani
Copy link
Author

@kyle-ssg Thank you for your response. I just tried flagsmith@9.0.2-beta.1 and the Angular build went through successfully.

@kyle-ssg
Copy link
Member

@ramtinsoltani This is now released in flagsmith@9.0.2, thanks for raising!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants