Git Product home page Git Product logo

Comments (4)

chernodub avatar chernodub commented on July 27, 2024 2

Maybe it'll be useful for some people. I was able to resolve the issue by using TS' merge declaration. Although be aware as it won't fail in case there is no such property in your env file.

// <project_root>/env.d.ts

declare namespace NodeJS {

  /** Merge declaration with `process` in order to override the global-scoped env. */
  export interface ProcessEnv {

    /**
     * Built-in environment variable.
     * @see Docs https://github.com/chihab/ngx-env#ng_app_env.
     */
    readonly NG_APP_ENV: string;

    // Add your environment variables below 
    /** Test data. */
    readonly NG_APP_TITLE: string;
  }
}

from ngx-env.

chihab avatar chihab commented on July 27, 2024

Shouldn't the definition file below do it?

declare var process: {
  env: {
    NG_APP_ENV: string;
    NG_APP_TITLE: string;
  };
};

Is the re-declaration error message only on VSCode or do you also get it on the command line (ng serve)?

from ngx-env.

chernodub avatar chernodub commented on July 27, 2024

The re-declaration is only on my IDE since the declaration file is not included in any of the applications in multiworkspace (by default). Anyway, your solution works great, thanks @chihab!

from ngx-env.

stephane-tessier avatar stephane-tessier commented on July 27, 2024

Hi

I have the same problem but I didn't understand the fix.

I have src/env.d.ts:

declare let process: {
  env: {
    NG_APP_ENV: string;
    // Replace the line below with your environment variable for better type checking
    NG_APP_apiHost: string;
    NG_APP_apiURL: string;
  };
};

and when I run my linter:

tsc --noEmit && eslint . --ext js,ts --quiet --fix

"Cannot redeclare block-scoped variable 'process'."

image

from ngx-env.

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.