Code Monkey home page Code Monkey logo

Comments (9)

blakeembrey avatar blakeembrey commented on June 30, 2024
typings/main/ambient/node/index.d.ts(329,22): error TS2304: Cannot find name 'Intl'.
typings/main/ambient/node/index.d.ts(355,25): error TS2304: Cannot find name 'console'.

from env-node.

louy avatar louy commented on June 30, 2024

I'm curious, but if console is a variable that might be declared in lib.d.ts wouldn't redeclaring it in node.d.ts cause duplicate declaration error and break for all users not using lib.core.d.ts?

from env-node.

blakeembrey avatar blakeembrey commented on June 30, 2024

@louy It shouldn't if the signatures are compatible, but we can check.

from env-node.

louy avatar louy commented on June 30, 2024

I've just tried adding message attribute to Error interface and it gave me an error. (I wanted to add a jsdoc comment)

node_modules/typescript/lib/lib.d.ts(880,5): error TS2300: Duplicate identifier 'message'.
4/node.d.ts(22,3): error TS2300: Duplicate identifier 'message'.

So I guess this won't work.

from env-node.

blakeembrey avatar blakeembrey commented on June 30, 2024

Hmm, I'll give it a shot too. Let me try, because they are technically different on node and browsers so it'd be good to type it correctly (and make it work if users are using the default browser typings).

from env-node.

louy avatar louy commented on June 30, 2024

I think it would be nice if we have a separate version with noLib support. Let me know once you've tried that.

from env-node.

blakeembrey avatar blakeembrey commented on June 30, 2024

@louy Sorry for the delay, I just confirmed it works perfectly fine (interfaces merge properly). The only issue I haven't resolved is new console.Console(process.stdout) that node allows.

from env-node.

blakeembrey avatar blakeembrey commented on June 30, 2024

@louy Actually, got it, easy. Just do:

declare interface Console {
  log (msg: any, ...params: any[]): void;
  info (msg: any, ...params: any[]): void;
  warn (msg: any, ...params: any[]): void;
  error (msg: any, ...params: any[]): void;
  dir (value: any, ...params: any[]): void;
  time (timerName?: string): void;
  timeEnd (timerName?: string): void;
  trace (msg: any, ...params: any[]): void;
  assert (test?: boolean, msg?: string, ...params: any[]): void;

  Console: new (stdout: any /* Change this to write-able stream */) => Console;
}

declare var console: Console;

from env-node.

louy avatar louy commented on June 30, 2024

Really? can you put it in a branch?

from env-node.

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.