SitePen / remap-istanbul

A tool for remapping Istanbul coverage via Source Maps
Other
240 stars 79 forks source link

Add typescript typings for remap-istanbul #155

Open silkentrance opened 6 years ago

silkentrance commented 6 years ago

I am currently working on building up a suite of gulp tasks and a gulpfile that are all implemented using typescript. For this, I use the compiler option "noImplicitAny": true.

Using that options will cause typescript to fail to compile my existing tasks that use remap-istanbul, as there is no type information for remap-istanbul available.

While I could define such typings myself, I'd rather would like these to be included directly into the package, so that I can reuse these typings from where ever I like. And others might also want this.

While one could publish the typings over at definitely typed, this would require a second party to maintain these typings, which is kind of counter productive.

What do you think?

silkentrance commented 6 years ago

An initial first stab at this would be to include gulpRemapIstanbul.d.ts in both lib/ and src/, e.g.

/// <reference types="node"/>

declare function RemapIstanbul(opts : RemapIstanbul.Options = {}) : NodeJS.ReadWriteStream;

declare namespace RemapIstanbul {
  interface Options {
    fail? : boolean;
    check?: CheckOptions;
    reportOpts?: {};
    reports?: {};
  }

  interface CheckOptions {
    global?: Thresholds;
    each?: EachThresholds;
  }

  interface Thresholds {
    statements: int = 0;
    branches: int = 0;
    lines: int = 0;
    functions: int = 0;
    excludes: string[] = [];
  }

  interface EachThresholds extends Thresholds {
    overrides?: {};
  }
}

export = RemapIstanbul;
demurgos commented 6 years ago

Thanks for working on this, it's a good thing. Since you're writing definitions for the package, it's good that you use external module definitions but you should leave out the Node reference. Add @types/node as a devDependency because it's an environment package.