[cli][client][error-utils][frameworks][fs-detectors][hydrogen][next][node-bridge][node][redwood][remix][routing-utils][static-config] update @types/node to v14 across repo (#8842)

### Related Issues

Updates @types/node to the latest version within the v14 major (based on `npm view @types/node`)

```
❯ npm view @types/node@'>=14.0.0 <15.0.0' version | tail -1
@types/node@14.18.33 '14.18.33'
```

This PR also fixes the various necessary type changes

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
This commit is contained in:
Ethan Arrowood
2022-11-04 14:21:13 -06:00
committed by GitHub
parent 9e5f17b3c6
commit 253b4fd1d2
22 changed files with 52 additions and 69 deletions

View File

@@ -16,7 +16,7 @@
"unzip-stream": "0.3.0" "unzip-stream": "0.3.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "13.1.4", "@types/node": "14.18.33",
"@types/node-fetch": "2.5.4", "@types/node-fetch": "2.5.4",
"@vercel/node": "1.9.0", "@vercel/node": "1.9.0",
"typescript": "3.9.6" "typescript": "3.9.6"

View File

@@ -81,7 +81,7 @@
"@types/minimatch": "3.0.3", "@types/minimatch": "3.0.3",
"@types/mri": "1.1.0", "@types/mri": "1.1.0",
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
"@types/node": "11.11.0", "@types/node": "14.18.33",
"@types/node-fetch": "2.5.10", "@types/node-fetch": "2.5.10",
"@types/npm-package-arg": "6.1.0", "@types/npm-package-arg": "6.1.0",
"@types/pluralize": "0.0.29", "@types/pluralize": "0.0.29",

View File

@@ -1,8 +1,7 @@
import { bold } from 'chalk'; import { bold } from 'chalk';
import inquirer from 'inquirer'; import inquirer from 'inquirer';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { URLSearchParams } from 'url'; import { URL } from 'url';
import { parse as parseUrl } from 'url';
import { VercelConfig } from '@vercel/client'; import { VercelConfig } from '@vercel/client';
import retry, { RetryFunction, Options as RetryOptions } from 'async-retry'; import retry, { RetryFunction, Options as RetryOptions } from 'async-retry';
import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch'; import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch';
@@ -87,25 +86,18 @@ export default class Client extends EventEmitter implements Stdio {
} }
private _fetch(_url: string, opts: FetchOptions = {}) { private _fetch(_url: string, opts: FetchOptions = {}) {
const parsedUrl = parseUrl(_url, true); const url = new URL(_url, this.apiUrl);
const apiUrl = parsedUrl.host
? `${parsedUrl.protocol}//${parsedUrl.host}`
: '';
if (opts.accountId || opts.useCurrentTeam !== false) { if (opts.accountId || opts.useCurrentTeam !== false) {
const query = new URLSearchParams(parsedUrl.query);
if (opts.accountId) { if (opts.accountId) {
if (opts.accountId.startsWith('team_')) { if (opts.accountId.startsWith('team_')) {
query.set('teamId', opts.accountId); url.searchParams.set('teamId', opts.accountId);
} else { } else {
query.delete('teamId'); url.searchParams.delete('teamId');
} }
} else if (opts.useCurrentTeam !== false && this.config.currentTeam) { } else if (opts.useCurrentTeam !== false && this.config.currentTeam) {
query.set('teamId', this.config.currentTeam); url.searchParams.set('teamId', this.config.currentTeam);
} }
_url = `${apiUrl}${parsedUrl.pathname}?${query}`;
} }
const headers = new Headers(opts.headers); const headers = new Headers(opts.headers);
@@ -122,7 +114,6 @@ export default class Client extends EventEmitter implements Stdio {
body = opts.body; body = opts.body;
} }
const url = `${apiUrl ? '' : this.apiUrl}${_url}`;
const requestId = this.requestIdCounter++; const requestId = this.requestIdCounter++;
return this.output.time(res => { return this.output.time(res => {
if (res) { if (res) {
@@ -130,7 +121,7 @@ export default class Client extends EventEmitter implements Stdio {
res.statusText res.statusText
}: ${res.headers.get('x-vercel-id')}`; }: ${res.headers.get('x-vercel-id')}`;
} else { } else {
return `#${requestId}${opts.method || 'GET'} ${url}`; return `#${requestId}${opts.method || 'GET'} ${url.href}`;
} }
}, fetch(url, { ...opts, headers, body })); }, fetch(url, { ...opts, headers, body }));
} }

View File

@@ -87,8 +87,12 @@ async function createBuildProcess(
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// The first message that the builder process sends is the `ready` event // The first message that the builder process sends is the `ready` event
buildProcess.once('message', ({ type }) => { buildProcess.once('message', data => {
if (type !== 'ready') { if (
data !== null &&
typeof data === 'object' &&
(data as { type: string }).type !== 'ready'
) {
reject(new Error('Did not get "ready" event from builder')); reject(new Error('Did not get "ready" event from builder'));
} else { } else {
resolve(buildProcess); resolve(buildProcess);

View File

@@ -31,11 +31,11 @@ export function parseListen(str: string, defaultPort = 3000): ListenSpec {
return [url.pathname]; return [url.pathname];
case 'tcp:': case 'tcp:':
url.port = url.port || String(defaultPort); url.port = url.port || String(defaultPort);
return [parseInt(url.port, 10), url.hostname]; return [parseInt(url.port, 10), url.hostname ?? undefined];
default: default:
if (!url.slashes) { if (!url.slashes) {
if (url.protocol === null) { if (url.protocol === null) {
return [defaultPort, url.pathname]; return [defaultPort, url.pathname ?? undefined];
} }
port = Number(url.hostname); port = Number(url.hostname);
if (url.protocol && !isNaN(port)) { if (url.protocol && !isNaN(port)) {

View File

@@ -4,7 +4,7 @@
* @param querystring - The querystring to parse, also known as the "search" string. * @param querystring - The querystring to parse, also known as the "search" string.
*/ */
export function parseQueryString( export function parseQueryString(
querystring?: string querystring?: string | null
): Record<string, string[]> { ): Record<string, string[]> {
const query: Record<string, string[]> = Object.create(null); const query: Record<string, string[]> = Object.create(null);
if (!querystring || !querystring.startsWith('?') || querystring === '?') { if (!querystring || !querystring.startsWith('?') || querystring === '?') {
@@ -38,9 +38,9 @@ export function parseQueryString(
*/ */
export function formatQueryString( export function formatQueryString(
query: Record<string, string[]> | undefined query: Record<string, string[]> | undefined
): string | undefined { ): string | null {
if (!query) { if (!query) {
return undefined; return null;
} }
let s = ''; let s = '';
let prefix = '?'; let prefix = '?';
@@ -55,5 +55,5 @@ export function formatQueryString(
prefix = '&'; prefix = '&';
} }
} }
return s || undefined; return s || null;
} }

View File

@@ -57,7 +57,8 @@ export async function devRouter(
phase?: HandleValue | null phase?: HandleValue | null
): Promise<RouteResult> { ): Promise<RouteResult> {
let result: RouteResult | undefined; let result: RouteResult | undefined;
let { pathname: reqPathname = '/', search: reqSearch } = url.parse(reqUrl); let { pathname: reqPathname, search: reqSearch } = url.parse(reqUrl);
reqPathname ??= '/';
const reqQuery = parseQueryString(reqSearch); const reqQuery = parseQueryString(reqSearch);
const combinedHeaders: HttpHeadersConfig = { ...previousHeaders }; const combinedHeaders: HttpHeadersConfig = { ...previousHeaders };
let status: number | undefined; let status: number | undefined;
@@ -130,7 +131,8 @@ export async function devRouter(
phase !== 'hit' && phase !== 'hit' &&
!isDestUrl !isDestUrl
) { ) {
const { pathname = '/' } = url.parse(destPath); let { pathname } = url.parse(destPath);
pathname ??= '/';
const hasDestFile = await devServer.hasFilesystem( const hasDestFile = await devServer.hasFilesystem(
pathname, pathname,
vercelConfig vercelConfig
@@ -186,8 +188,9 @@ export async function devRouter(
if (!destPath.startsWith('/')) { if (!destPath.startsWith('/')) {
destPath = `/${destPath}`; destPath = `/${destPath}`;
} }
const { pathname: destPathname = '/', search: destSearch } = let { pathname: destPathname, search: destSearch } =
url.parse(destPath); url.parse(destPath);
destPathname ??= '/';
const destQuery = parseQueryString(destSearch); const destQuery = parseQueryString(destSearch);
Object.assign(destQuery, reqQuery); Object.assign(destQuery, reqQuery);
result = { result = {

View File

@@ -23,24 +23,24 @@ describe('parseQueryString', () => {
const parsed = parseQueryString(''); const parsed = parseQueryString('');
expect(parsed).toEqual({}); expect(parsed).toEqual({});
const format = formatQueryString(parsed); const format = formatQueryString(parsed);
expect(format).toEqual(undefined); expect(format).toEqual(null);
}); });
it('should work with question mark', async () => { it('should work with question mark', async () => {
const parsed = parseQueryString('?'); const parsed = parseQueryString('?');
expect(parsed).toEqual({}); expect(parsed).toEqual({});
const format = formatQueryString(parsed); const format = formatQueryString(parsed);
expect(format).toEqual(undefined); expect(format).toEqual(null);
}); });
it('should work without question mark', async () => { it('should work without question mark', async () => {
const parsed = parseQueryString('blarg'); const parsed = parseQueryString('blarg');
expect(parsed).toEqual({}); expect(parsed).toEqual({});
const format = formatQueryString(parsed); const format = formatQueryString(parsed);
expect(format).toEqual(undefined); expect(format).toEqual(null);
}); });
it('should work with undefined', async () => { it('should work with undefined', async () => {
const parsed = parseQueryString(undefined); const parsed = parseQueryString(undefined);
expect(parsed).toEqual({}); expect(parsed).toEqual({});
const format = formatQueryString(parsed); const format = formatQueryString(parsed);
expect(format).toEqual(undefined); expect(format).toEqual(null);
}); });
}); });

View File

@@ -28,7 +28,7 @@
"@types/jest": "27.4.1", "@types/jest": "27.4.1",
"@types/minimatch": "3.0.5", "@types/minimatch": "3.0.5",
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
"@types/node": "12.0.4", "@types/node": "14.18.33",
"@types/node-fetch": "2.5.4", "@types/node-fetch": "2.5.4",
"@types/recursive-readdir": "2.2.0", "@types/recursive-readdir": "2.2.0",
"@types/tar-fs": "1.16.1", "@types/tar-fs": "1.16.1",

View File

@@ -17,7 +17,7 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/jest": "29.2.1", "@types/jest": "29.2.1",
"@types/node": "16.11.7", "@types/node": "14.18.33",
"jest": "29.2.2", "jest": "29.2.2",
"ts-jest": "29.0.3", "ts-jest": "29.0.3",
"typescript": "^4.8.4" "typescript": "^4.8.4"

View File

@@ -19,7 +19,7 @@
"devDependencies": { "devDependencies": {
"@types/jest": "27.4.1", "@types/jest": "27.4.1",
"@types/js-yaml": "3.12.1", "@types/js-yaml": "3.12.1",
"@types/node": "12.0.4", "@types/node": "14.18.33",
"@types/node-fetch": "2.5.8", "@types/node-fetch": "2.5.8",
"@vercel/routing-utils": "2.1.1", "@vercel/routing-utils": "2.1.1",
"ajv": "6.12.2", "ajv": "6.12.2",

View File

@@ -32,7 +32,7 @@
"@types/jest": "27.5.1", "@types/jest": "27.5.1",
"@types/js-yaml": "4.0.5", "@types/js-yaml": "4.0.5",
"@types/minimatch": "3.0.5", "@types/minimatch": "3.0.5",
"@types/node": "12.12.20", "@types/node": "14.18.33",
"@types/semver": "7.3.10", "@types/semver": "7.3.10",
"@vercel/build-utils": "4.2.0", "@vercel/build-utils": "4.2.0",
"typescript": "4.3.4" "typescript": "4.3.4"

View File

@@ -20,7 +20,7 @@
], ],
"devDependencies": { "devDependencies": {
"@types/jest": "27.5.1", "@types/jest": "27.5.1",
"@types/node": "*", "@types/node": "14.18.33",
"@vercel/build-utils": "5.5.7", "@vercel/build-utils": "5.5.7",
"@vercel/static-config": "2.0.5", "@vercel/static-config": "2.0.5",
"typescript": "4.6.4" "typescript": "4.6.4"

View File

@@ -39,7 +39,7 @@
"@types/fs-extra": "8.0.0", "@types/fs-extra": "8.0.0",
"@types/glob": "7.1.3", "@types/glob": "7.1.3",
"@types/next-server": "8.0.0", "@types/next-server": "8.0.0",
"@types/node": "14.17.27", "@types/node": "14.18.33",
"@types/resolve-from": "5.0.1", "@types/resolve-from": "5.0.1",
"@types/semver": "6.0.0", "@types/semver": "6.0.0",
"@types/text-table": "0.2.1", "@types/text-table": "0.2.1",

View File

@@ -22,7 +22,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/aws-lambda": "8.10.19", "@types/aws-lambda": "8.10.19",
"@types/node": "*", "@types/node": "14.18.33",
"jsonlines": "0.1.1", "jsonlines": "0.1.1",
"test-listen": "1.1.0", "test-listen": "1.1.0",
"typescript": "4.3.4" "typescript": "4.3.4"

View File

@@ -30,7 +30,7 @@
}, },
"dependencies": { "dependencies": {
"@edge-runtime/vm": "2.0.0", "@edge-runtime/vm": "2.0.0",
"@types/node": "*", "@types/node": "14.18.33",
"@vercel/build-utils": "5.5.7", "@vercel/build-utils": "5.5.7",
"@vercel/node-bridge": "3.1.1", "@vercel/node-bridge": "3.1.1",
"@vercel/static-config": "2.0.5", "@vercel/static-config": "2.0.5",

View File

@@ -25,7 +25,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/aws-lambda": "8.10.19", "@types/aws-lambda": "8.10.19",
"@types/node": "*", "@types/node": "14.18.33",
"@types/semver": "6.0.0", "@types/semver": "6.0.0",
"@vercel/build-utils": "5.5.7" "@vercel/build-utils": "5.5.7"
} }

View File

@@ -24,7 +24,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "27.5.1", "@types/jest": "27.5.1",
"@types/node": "*", "@types/node": "14.18.33",
"@vercel/build-utils": "5.5.7", "@vercel/build-utils": "5.5.7",
"typescript": "4.6.4" "typescript": "4.6.4"
} }

View File

@@ -23,7 +23,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "27.4.1", "@types/jest": "27.4.1",
"@types/node": "12.12.20", "@types/node": "14.18.33",
"ajv": "^6.0.0", "ajv": "^6.0.0",
"typescript": "4.3.4" "typescript": "4.3.4"
}, },

View File

@@ -297,7 +297,12 @@ function replaceSegments(
safelyCompile(unescapeSegments(str), indexes, true) safelyCompile(unescapeSegments(str), indexes, true)
); );
} else { } else {
query[key] = safelyCompile(unescapeSegments(strOrArray), indexes, true); // TODO: handle strOrArray is undefined
query[key] = safelyCompile(
unescapeSegments(strOrArray as string),
indexes,
true
);
} }
} }

View File

@@ -24,7 +24,7 @@
"devDependencies": { "devDependencies": {
"@swc/core": "1.2.182", "@swc/core": "1.2.182",
"@types/jest": "27.4.1", "@types/jest": "27.4.1",
"@types/node": "*" "@types/node": "14.18.33"
}, },
"jest": { "jest": {
"preset": "ts-jest", "preset": "ts-jest",

View File

@@ -3033,30 +3033,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67"
integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ== integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==
"@types/node@11.11.0": "@types/node@14.18.33":
version "11.11.0" version "14.18.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.0.tgz#070e9ce7c90e727aca0e0c14e470f9a93ffe9390" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.33.tgz#8c29a0036771569662e4635790ffa9e057db379b"
integrity sha512-D5Rt+HXgEywr3RQJcGlZUCTCx1qVbCZpVk3/tOOA6spLNZdGm8BU+zRgdRYDoF1pO3RuXLxADzMrF903JlQXqg== integrity sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==
"@types/node@12.0.4":
version "12.0.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.4.tgz#46832183115c904410c275e34cf9403992999c32"
integrity sha512-j8YL2C0fXq7IONwl/Ud5Kt0PeXw22zGERt+HSSnwbKOJVsAGkEz3sFCYwaF9IOuoG1HOtE0vKCj6sXF7Q0+Vaw==
"@types/node@12.12.20":
version "12.12.20"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.20.tgz#7b693038ce661fe57a7ffa4679440b5e7c5e8b99"
integrity sha512-VAe+DiwpnC/g448uN+/3gRl4th0BTdrR9gSLIOHA+SUQskaYZQDOHG7xmjiE7JUhjbXnbXytf6Ih+/pA6CtMFQ==
"@types/node@14.17.27":
version "14.17.27"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.27.tgz#5054610d37bb5f6e21342d0e6d24c494231f3b85"
integrity sha512-94+Ahf9IcaDuJTle/2b+wzvjmutxXAEXU6O81JHblYXUg2BDG+dnBy7VxIPHKAyEEDHzCMQydTJuWvrE+Aanzw==
"@types/node@16.11.7":
version "16.11.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.7.tgz#36820945061326978c42a01e56b61cd223dfdc42"
integrity sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw==
"@types/normalize-package-data@^2.4.0": "@types/normalize-package-data@^2.4.0":
version "2.4.0" version "2.4.0"