Skip to content

Add Typescript types #6

@0vidiu

Description

@0vidiu

Hello,

Since I found your module helpful I'd like to contribute with the Typescript type declarations. This is my first go at this so, not entirely sure it's 100% correct, but it seems to work fine for me. I wrote this so Typescript compiler would stops bugging me. Maybe it will be helpful to others, as well.

declare module 'test-console' {
  type Callback = (output: string) => void;
  type Output = string[];
  type Options = {
    [key: string]: any;
    isTTY?: boolean;
  };
  type Inspector = {
    output: Output;
    restore(): void;
  };

  export const stdout: {
    inspect(options?: Options): Inspector,
    inspectSync(fn: Callback);
    inspectSync(options: Options, fn?: Callback): Output,
    ignore(options?: Options): void,
    ignoreSync(fn: Callback): void,
    ignoreSync(options: Options, fn?: Callback): void,
  };

  export const stderr: {
    inspect(options?: Options): Inspector,
    inspectSync(fn: Callback): Output,
    inspectSync(options: Options, fn?: Callback): Output,
    ignore(options?: Options): void,
    ignoreSync(fn: Callback): string,
    ignoreSync(options: Options, fn?: Callback): string,
  };
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions