Git Product home page Git Product logo

Comments (5)

murunwas avatar murunwas commented on July 27, 2024 7

add skipLibCheck": true on your tsconfig to fix the error

from ngx-env.

fullpipe avatar fullpipe commented on July 27, 2024 1

I think it is better to exclude just src/env.d.ts

"exclude": ["src/env.d.ts"],

from ngx-env.

chernodub avatar chernodub commented on July 27, 2024 1

Figured a better way to merge process types:

declare namespace NodeJS {
  export interface ProcessEnv {
    /**
     * Built-in environment variable.
     * @see Docs https://github.com/chihab/ngx-env#ng_app_env.
     */
    readonly NG_APP_ENV: string;

    // Replace the line below with your environment variable for better type checking
    readonly [key: string]: any;
  }
}

from ngx-env.

chihab avatar chihab commented on July 27, 2024

Is it a project from scratch? If not could you please try to reproduce you error in a project from scratch?

npx @angular/cli@11 new ng-app11
cd ng-app11 && npx ng add @ngx-env/[email protected]
npm start

With that, if you don't have the error (I hope so), try to spot the difference with your project?

Could you please share your Angular and TS exact versions?

Thanks @widipa

from ngx-env.

chernodub avatar chernodub commented on July 27, 2024

Hi @chihab. I created the project from scratch (via npx -p @angular/cli ng new and npx ng add @ngx-env/builder) and faced the same issue. Please see my repository with a reproduction of the issue https://github.com/chernodub/ngx-env-repro/.

Error: src/env.d.ts:1:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'process' must be of type 'Process', but here has type '{ env: { [key: string]: any; NG_APP_ENV: string; }; }'.

1 declare var process: {
              ~~~~~~~

  node_modules/@types/node/ts4.8/globals.d.ts:27:13
    27 declare var process: NodeJS.Process;
                   ~~~~~~~
    'process' was also declared here.

💡 By the way, to solve the issue, I believe it would be more reasonable to add @ts-ignore to env.d.ts, rather than disabling the lib check for the whole project (via skipLibCheck)

// To silently merge declarations with global process
// @ts-ignore
declare var process: {
  env: {
    NG_APP_ENV: string;
    // Replace the line below with your environment variable for better type checking
    [key: string]: any;
  };
};

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.