Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore mock client TS errors #11345

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions .changeset/hip-lizards-whisper.md
@@ -0,0 +1,6 @@
---
'@vercel-internals/types': patch
'vercel': patch
---

Update stdio types for cli client
7 changes: 2 additions & 5 deletions internals/types/index.d.ts
@@ -1,5 +1,4 @@
import type { BuilderFunctions } from '@vercel/build-utils';
import type { Readable, Writable } from 'stream';
import type * as tty from 'tty';
import type { Route } from '@vercel/routing-utils';
import { PROJECT_ENV_TARGET } from '@vercel-internals/constants';
Expand Down Expand Up @@ -628,15 +627,13 @@ export interface BuildOutput {
} | null;
}

export interface ReadableTTY extends Readable {
export interface ReadableTTY extends tty.ReadStream {
isTTY?: boolean;
isRaw?: boolean;
setRawMode?: (mode: boolean) => void;
}

export interface WritableTTY extends Writable {
isTTY?: boolean;
}
export type WritableTTY = tty.WriteStream;

export interface Stdio {
stdin: ReadableTTY;
Expand Down
18 changes: 8 additions & 10 deletions packages/cli/test/mocks/client.ts
Expand Up @@ -11,6 +11,7 @@ import express, { Express, Router } from 'express';
import { listen } from 'async-listen';
import Client from '../../src/util/client';
import { Output } from '../../src/util/output';
import { ReadableTTY, WritableTTY } from '@vercel-internals/types';

// Disable colors in `chalk` so that tests don't need
// to worry about ANSI codes
Expand All @@ -32,9 +33,6 @@ class MockStream extends PassThrough {
}

export class MockClient extends Client {
stdin!: MockStream;
stdout!: MockStream;
stderr!: MockStream;
scenario: Scenario;
mockServer?: Server;
private app: Express;
Expand All @@ -49,10 +47,10 @@ export class MockClient extends Client {
authConfig: {},
config: {},
localConfig: {},
stdin: new PassThrough(),
stdout: new PassThrough(),
stderr: new PassThrough(),
output: new Output(new PassThrough()),
stdin: new PassThrough() as unknown as ReadableTTY,
stdout: new PassThrough() as unknown as WritableTTY,
stderr: new PassThrough() as unknown as WritableTTY,
output: new Output(new PassThrough() as unknown as WritableTTY),
});

this.app = express();
Expand Down Expand Up @@ -81,14 +79,14 @@ export class MockClient extends Client {
}

reset() {
this.stdin = new MockStream();
this.stdin = new MockStream() as unknown as WritableTTY;

this.stdout = new MockStream();
this.stdout = new MockStream() as unknown as WritableTTY;
this.stdout.setEncoding('utf8');
this.stdout.end = () => this.stdout;
this.stdout.pause();

this.stderr = new MockStream();
this.stderr = new MockStream() as unknown as WritableTTY;
this.stderr.setEncoding('utf8');
this.stderr.end = () => this.stderr;
this.stderr.pause();
Expand Down