Skip to content

Commit

Permalink
fix: fix type errors exposed by node 14 typings
Browse files Browse the repository at this point in the history
- fix(bundle-size): fix type errors exposed by node 14 typings
- fix(tools): fix type errors exposed by node 14 typings
- fix(typings): fix type errors exposed by node 14 typings
- fix(scripts): fix type errors exposed by node 14 typings
  • Loading branch information
Hotell committed Nov 8, 2022
1 parent 16c9248 commit 2781dbd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/bundle-size/src/utils/buildFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ module.exports = async function buildFixture(preparedFixture, quiet) {
/* eslint-enable @typescript-eslint/naming-convention */
]);

await fs.writeFile(webpackOutputPath, terserOutput.code);
await fs.writeFile(terserOutputPath, terserOutputMinified.code);
await fs.writeFile(webpackOutputPath, terserOutput.code ?? '');
await fs.writeFile(terserOutputPath, terserOutputMinified.code ?? '');

if (!quiet) {
console.log(
Expand Down
7 changes: 6 additions & 1 deletion packages/bundle-size/src/utils/prepareFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const ajv = new Ajv();
/** @typedef {{ name: string }} FixtureMetadata */
/** @typedef {{ absolutePath: string, relativePath: string, name: string }} PreparedFixture */

/**
* @template T
* @typedef {NonNullable<T> & {[P in keyof T]-?: NonNullable<T[P]>;}} RequiredNonNullableRecord<T>
*/

/**
* Prepares a fixture file to be compiled with Webpack, grabs data from a default export and removes it.
*
Expand Down Expand Up @@ -59,7 +64,7 @@ module.exports = async function prepareFixture(fixture) {

/**
* @param {typeof result} value
* @return {value is Required<NonNullable<typeof result>> & {metadata: FixtureMetadata}}
* @return {value is RequiredNonNullableRecord<typeof result> & {metadata: FixtureMetadata}}
*/
function isTransformedFixtureResultHasMetadata(value) {
return Boolean(value && value.metadata && Object.keys(value.metadata).length);
Expand Down
4 changes: 2 additions & 2 deletions scripts/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ function exec(cmd, displayName, cwd = process.cwd(), opts = {}) {
);

if (opts.stdout) {
child.stdout.pipe(opts.stdout);
child.stdout?.pipe(opts.stdout);
}
if (opts.stderr) {
child.stderr.pipe(opts.stderr);
child.stderr?.pipe(opts.stderr);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions tools/generators/epic-generator/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function setupTest(packages: Package[]) {

// response to 'gh auth'
spawnSyncMock.mockReturnValueOnce({
output: ['Logged in to github.com'],
output: [['Logged in to github.com']],
});

// response to epic creation
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('epic-generator', () => {

it('requires you to have logged in with gh', () => {
spawnSyncMock.mockReturnValueOnce({
output: ['You are not logged into any GitHub hosts. Run gh auth login to authenticate.'],
output: [['You are not logged into any GitHub hosts. Run gh auth login to authenticate.']],
});

const tree = createTreeWithEmptyWorkspace();
Expand Down
2 changes: 1 addition & 1 deletion typings/json-stable-stringify-without-jsonify/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Type definitions for json-stable-stringify-without-jsonify 1.0.1

declare module 'json-stable-stringify-without-jsonify' {
function stringify(value: Record<string, any>, options?: Partial<Options>): Record<string, any>;
function stringify(value: Record<string, any>, options?: Partial<Options>): string;

interface Options {
cmp: (a: any, b: any) => any;
Expand Down

0 comments on commit 2781dbd

Please sign in to comment.