Skip to content

Add Typescript types #6

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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