Skip to content

refactor: use node v12 types, matching WORKSPACE version #17653

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.13
12.14
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"@types/loader-utils": "^1.1.3",
"@types/minimatch": "3.0.3",
"@types/minimist": "^1.2.0",
"@types/node": "10.12.30",
"@types/node": "13.13.5",
"@types/node-fetch": "^2.1.6",
"@types/npm-package-arg": "^6.1.0",
"@types/progress": "^2.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ if (process.env['NG_CLI_PROFILING']) {
standardInput = process.stdin;
} catch (e) {
delete process.stdin;
process.stdin = new Duplex();
process.stdin = new Duplex() as NodeJS.ReadStream;
standardInput = process.stdin;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/benchmark/src/monitored-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class LocalMonitoredProcess implements MonitoredProcess {
const childProcess = spawn(cmd, args, spawnOptions);

// Emit output and stats.
childProcess.stdout.on('data', (data: Buffer) => this.stdout.next(data));
childProcess.stderr.on('data', (data: Buffer) => this.stderr.next(data));
childProcess.stdout?.on('data', (data: Buffer) => this.stdout.next(data));
childProcess.stderr?.on('data', (data: Buffer) => this.stderr.next(data));
const statsSubs = timer(0, this.pollingRate).pipe(
concatMap(() => from(pidtree(childProcess.pid, { root: true }))),
concatMap((pids: number[]) => from(pidusage(pids, { maxage: 5 * this.pollingRate }))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function serveWebpackBrowser(
publicHost = `${options.ssl ? 'https' : 'http'}://${publicHost}`;
}
clientAddress = url.parse(publicHost);
options.publicHost = clientAddress.host;
options.publicHost = clientAddress.host ?? undefined;
}

// Add live reload config.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export function runWebpackDevServer(
obs.error(err);
} else {
const address = this.address();
if (address === null) {
throw new Error('Server is not listening');
}
result = {
success: true,
port: typeof address === 'string' ? 0 : address.port,
Expand Down
12 changes: 6 additions & 6 deletions packages/angular_devkit/core/node/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ function loadFSWatcher() {
}
}

type FsFunction0<R> = (cb: (err?: Error, result?: R) => void) => void;
type FsFunction1<R, T1> = (p1: T1, cb: (err?: Error, result?: R) => void) => void;
type FsFunction0<R> = (cb: (err?: Error|null, result?: R) => void) => void;
type FsFunction1<R, T1> = (p1: T1, cb: (err?: Error|null, result?: R) => void) => void;
type FsFunction2<R, T1, T2>
= (p1: T1, p2: T2, cb: (err?: Error, result?: R) => void) => void;
= (p1: T1, p2: T2, cb: (err?: Error|null, result?: R) => void) => void;


function _callFs<R>(fn: FsFunction0<R>): Observable<R>;
Expand All @@ -70,7 +70,7 @@ function _callFs<R, T1, T2>(fn: FsFunction2<R, T1, T2>, p1: T1, p2: T2): Observa

function _callFs<ResultT>(fn: Function, ...args: {}[]): Observable<ResultT> {
return new Observable(obs => {
fn(...args, (err?: Error, result?: ResultT) => {
fn(...args, (err?: Error|null, result?: ResultT) => {
if (err) {
obs.error(err);
} else {
Expand Down Expand Up @@ -176,12 +176,12 @@ export class NodeJsAsyncHost implements virtualFs.Host<fs.Stats> {
}

isDirectory(path: Path): Observable<boolean> {
return _callFs(fs.stat, getSystemPath(path)).pipe(
return _callFs<fs.Stats, string>(fs.stat, getSystemPath(path)).pipe(
map(stat => stat.isDirectory()),
);
}
isFile(path: Path): Observable<boolean> {
return _callFs(fs.stat, getSystemPath(path)).pipe(
return _callFs<fs.Stats, string>(fs.stat, getSystemPath(path)).pipe(
map(stat => stat.isFile()),
);
}
Expand Down
5 changes: 2 additions & 3 deletions packages/angular_devkit/core/src/terminal/caps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/
import ReadableStream = NodeJS.ReadableStream;
import WriteStream = NodeJS.WriteStream;
import Socket = NodeJS.Socket;
const supportsColor = require('../../third_party/github.com/chalk/supports-color');

/**
Expand Down Expand Up @@ -76,7 +75,7 @@ function _getColumns() {


function _createCapabilities(
stream: Socket,
stream: WriteStream,
isTerminalStream: boolean,
level: 0|1|2|3 = supportsColor.stdout.level,
): StreamCapabilities {
Expand All @@ -96,7 +95,7 @@ function _createCapabilities(


export function getCapabilities(
stream: Socket,
stream: WriteStream,
isTerminalStream = !!stream.isTTY,
): StreamCapabilities {
let maybeCaps = streamMap.get(stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export default function(
}
});
if (options.hideOutput) {
childProcess.stdout.on('data', (data: Buffer) =>
childProcess.stdout?.on('data', (data: Buffer) =>
bufferedOutput.push({ stream: process.stdout, data: data }));
childProcess.stderr.on('data', (data: Buffer) =>
childProcess.stderr?.on('data', (data: Buffer) =>
bufferedOutput.push({ stream: process.stderr, data: data }));
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ export class AngularCompilerPlugin {

// Handle child messages.
this._typeCheckerProcess.on('message', message => {
switch (message.kind) {
switch ((message as {kind: MESSAGE_KIND}).kind) {
case MESSAGE_KIND.Log:
const logMessage = message as LogMessage;
this._logger.log(logMessage.level, `\n${logMessage.message}`);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"./node_modules/@types"
],
"types": [
"node"
"node/v12"
],
"paths": {
"@_/benchmark": [ "./packages/_/benchmark/src/index" ],
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1453,10 +1453,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.4.tgz#1581d6c16e3d4803eb079c87d4ac893ee7501c2c"
integrity sha512-x26ur3dSXgv5AwKS0lNfbjpCakGIduWU1DU91Zz58ONRWrIKGunmZBNv4P7N+e27sJkiGDsw/3fT4AtsqQBrBA==

"@types/node@10.12.30":
version "10.12.30"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.30.tgz#4c2b4f0015f214f8158a347350481322b3b29b2f"
integrity sha512-nsqTN6zUcm9xtdJiM9OvOJ5EF0kOI8f1Zuug27O/rgtxCRJHGqncSWfCMZUP852dCKPsDsYXGvBhxfRjDBkF5Q==
"@types/node@13.13.5":
version "13.13.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.5.tgz#96ec3b0afafd64a4ccea9107b75bf8489f0e5765"
integrity sha512-3ySmiBYJPqgjiHA7oEaIo2Rzz0HrOZ7yrNO5HWyaE5q0lQ3BppDZ3N53Miz8bw2I7gh1/zir2MGVZBvpb1zq9g==

"@types/node@^10.1.0":
version "10.17.21"
Expand Down