Code Monkey home page Code Monkey logo

env-node's People

Contributors

blakeembrey avatar cjbarth avatar ericbyers avatar greenkeeper[bot] avatar itbrandonsilva avatar louy avatar neomantra avatar nickzelei avatar poislagarde avatar unional avatar voxlet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

env-node's Issues

Add `console` interfaces

Something I've always wanted to do. When writing node programs I really want to disable the default library and just use lib.core.d.ts to avoid bugs that occur from including all of lib.d.ts. However, this isn't possible with the current definitions because console is not part of lib.core.d.ts or node.d.ts.

7.0.8 Breaks when used with @types/Core-js

They disagree about the type of "iterator." The new version of @types/node states that the iterator is "readonly," whereas the most recent version of types for @types/core-js does not say "readonly," resulting in the following error:

504     iterator: symbol;
        ~~~~~~~~

node_modules/@types/core-js/index.d.ts(504,5): error TS2687: All declarations of 'iterator' must have identical modifiers.


50     readonly iterator: symbol;
                ~~~~~~~~

node_modules/@types/node/index.d.ts(50,14): error TS2687: All declarations of 'iterator' must have identical modifiers.

Unfortunately we're targeting Nodejs v4.3 (using AWS Lambda, which hasn't updated their node runtime in a long time and doesn't seem eager to do so soon), so we need some of the polyfills from core-js in order to make our code work.

process.stdout should be WritableStream | tty.WriteStream

From https://nodejs.org/api/tty.html#tty_tty:

When Node.js detects that it is being run inside a text terminal ("TTY") context, the process.stdin will, by default, be initialized as an instance of tty.ReadStream and both process.stdout and process.stderr will, by default be instances of tty.WriteStream. The preferred method of determining whether Node.js is being run within a TTY context is to check that the value of the process.stdout.isTTY property is true:

$ node -p -e "Boolean(process.stdout.isTTY)"
true
$ node -p -e "Boolean(process.stdout.isTTY)" | cat
false

It's currently not possible to check process.stdout.isTTY because it is only typed as WritableStream. It should be WritableStream | tty.WriteStream.

The alternative check process.stdout instanceof tty.WriteStream is not possible either, because tty only exports interfaces, not the classes / constructors.

The same applies to process.stdin/tty.ReadStream

ES2015 Collection Type Definitions

Node.JS has used a V8 engine which has supported ES2015 Map/Set constructors since 2.0.0 so it would be useful if their definitions could be added to the [email protected] definition.

The definitions themselves can probably be based on the definition in lib.es6.d.ts.

extend type define of NodeJS.Process.env

installed: registry:dt/node#6.0.0+20160907103612

current content:

 export interface Process extends EventEmitter {
/// ....
    env: any;
/// ....
}

may change to:

export interface EnvironmentVariables {
    [key: string]: string;
}
export interface Process extends EventEmitter {
/// ....
    env: NodeJS.EnvironmentVariables;
/// ....
}

then users can extend env in their own .d.ts:

declare namespace NodeJS {
    export interface EnvironmentVariables {
        SOME_THING: string;
        SOME_OTHER_THING: string;
    }
}

currently this will cause error TS2403: Subsequent variable declarations must have the same type. Variable 'env' must be of type 'any', but here has type 'IProcessEnv':

interface IProcessEnv {
    SOME_THING: string;
    SOME_OTHER_THING: string;
}
declare namespace NodeJS {
    export interface Process {
        env: IProcessEnv;
    }
}

Duplicate identifier 'stack' with TS 1.9

Hi,
Typescript 1.9 (currently typescript@next) adds definitions for Error.prototype.stack.

It results in a duplicate identifier

C:/Users/Charles/AppData/Roaming/npm/node_modules/typescript/lib/lib.d.ts(883,5): error TS2300: Duplicate identifier 'stack'.
typings/globals/node/index.d.ts(19,3): error TS2300: Duplicate identifier 'stack'.

How do you plan to handle this sort of changes ? Should we remove stack from this definition once TS 1.9 is stable ?

Old definitions in registry

It seems that the typings registry has an old version of these typings. How can these be updated? I see two commits to master since these were last updated. Granted, one was just today, but the other was some days ago.

TAG                   VERSION DESCRIPTION COMPILER LOCATION                                                            UPDATED                 
6.0.0+20161105011511  6.0.0                        github:types/env-node/6.0#088b6275167df0e4bec9bee3205c703253ef4ace  2016-11-05T01:15:11.000Z
4.0.0+20161105011511  4.0.0                        github:types/env-node/4.0#088b6275167df0e4bec9bee3205c703253ef4ace  2016-11-05T01:15:11.000Z
0.12.0+20161105011511 0.12.0                       github:types/env-node/0.12#088b6275167df0e4bec9bee3205c703253ef4ace 2016-11-05T01:15:11.000Z
0.10.0+20161105011511 0.10.0                       github:types/env-node/0.10#088b6275167df0e4bec9bee3205c703253ef4ace 2016-11-05T01:15:11.000Z

Make sure there's `noImplicitAny`

typings/main/ambient/node/index.d.ts(69,3): error TS7010: 'stackTraceLimit', which lacks return-type annotation, implicitly has an 'any' return type.

readFileSync `options` can be null

export function readFileSync(filename: string, options: ReadFileOptions): Buffer;
and
export function readFile(filename: string, options: ReadFileOptions, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;

should be:

export function readFileSync(filename: string, options: ReadFileOptions | null): Buffer;
and
export function readFile(filename: string, options: ReadFileOptions | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;

I can create a PR if desired.

Broken with newest es6.lib.d.ts

Definition of WeakMap in newest es6.lib.d.ts:

interface WeakMap<K extends object, V> { }

interface WeakMapConstructor {
    new <K extends object, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
}

Definition in Node typings:

interface WeakMap<K, V> extends NodeWeakCollection {
  clear(): void;
  delete(key: K): boolean;
  get(key: K): V | void;
  has(key: K): boolean;
  set(key: K, value?: V): WeakMap<K, V>;
}

interface WeakMapConstructor extends NodeCollectionConstructor<WeakMap<any, any>> {
  new (): WeakMap<any, any>;
  new <K, V>(): WeakMap<K, V>;
}

Error:

typings/globals/node/index.d.ts(108,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
typings/globals/node/index.d.ts(118,25): error TS2344: Type 'K' does not satisfy the constraint 'object'.

Should we really define WeakMap in the Node typings if it is clearly part of ES6 spec and should therefor be provided by es6.lib.d.ts?

/cc @blakeembrey

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.