Skip to content

Commit

Permalink
chore(testlab): work around a regression by @types/[email protected]
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Feng <[email protected]>
  • Loading branch information
raymondfeng committed Sep 3, 2020
1 parent dc6e661 commit 1bc1c5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/testlab/src/shot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,15 @@ function defineCustomContextInspect(
});
}

// @types/node@v10.17.29 seems to miss the type definition of `util.inspect.custom`
// error TS2339: Property 'custom' does not exist on type 'typeof inspect'.
// Use a workaround for now to access the `custom` symbol for now.
// https://nodejs.org/api/util.html#util_util_inspect_custom
const custom = Symbol.for('nodejs.util.inspect.custom');

function defineCustomInspect(
obj: any,
inspectFn: (depth: number, opts: any) => {},
) {
obj[util.inspect.custom] = inspectFn;
obj[custom] = inspectFn;
}

0 comments on commit 1bc1c5f

Please sign in to comment.