From a7792bc5b4a32eb0b842cf4ff328aef09bb590de Mon Sep 17 00:00:00 2001 From: Sergei Zharinov <zharinov@users.noreply.github.com> Date: Wed, 17 Nov 2021 12:32:33 +0300 Subject: [PATCH] refactor(typescript): Refactor more files (#12696) Co-authored-by: Rhys Arkins <rhys@arkins.net> --- lib/types/errors/external-host-error.ts | 2 +- lib/util/mask.spec.ts | 3 ++- lib/util/mask.ts | 2 +- test/graphql-snapshot.ts | 6 ++++-- tsconfig.strict.json | 4 ++++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/types/errors/external-host-error.ts b/lib/types/errors/external-host-error.ts index 88f4fdb936..5fd5922966 100644 --- a/lib/types/errors/external-host-error.ts +++ b/lib/types/errors/external-host-error.ts @@ -1,7 +1,7 @@ import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages'; export class ExternalHostError extends Error { - hostType: string; + hostType: string | undefined; err: Error; diff --git a/lib/util/mask.spec.ts b/lib/util/mask.spec.ts index a3150839d1..e7cdb0816c 100644 --- a/lib/util/mask.spec.ts +++ b/lib/util/mask.spec.ts @@ -2,7 +2,8 @@ import { maskToken } from './mask'; describe('util/mask', () => { describe('.maskToken', () => { - it('returns value if passed value is falsy', () => { + it('returns empty string if passed value is falsy', () => { + expect(maskToken()).toBe(''); expect(maskToken('')).toBe(''); }); diff --git a/lib/util/mask.ts b/lib/util/mask.ts index dd50d43366..83fa009a35 100644 --- a/lib/util/mask.ts +++ b/lib/util/mask.ts @@ -5,5 +5,5 @@ export function maskToken(str?: string): string { new Array(str.length - 3).join('*'), str.slice(-2), ].join('') - : str; + : ''; } diff --git a/test/graphql-snapshot.ts b/test/graphql-snapshot.ts index 66e7f9f3eb..75478315b4 100644 --- a/test/graphql-snapshot.ts +++ b/test/graphql-snapshot.ts @@ -37,11 +37,13 @@ type Variables = Record<string, string>; interface SelectionSet { __vars?: Variables; __args?: Arguments; - [key: string]: null | SelectionSet | Arguments; + [key: string]: undefined | null | SelectionSet | Arguments; } interface GraphqlSnapshot { query?: SelectionSet; + mutation?: SelectionSet; + subscription?: SelectionSet; variables?: Record<string, string>; } @@ -81,7 +83,7 @@ function getArguments(key: string, val: ValueNode): Arguments { } function simplifyArguments( - argNodes: ReadonlyArray<ArgumentNode> + argNodes?: ReadonlyArray<ArgumentNode> ): Arguments | null { if (argNodes) { let result: Arguments = {}; diff --git a/tsconfig.strict.json b/tsconfig.strict.json index efec9fbfe0..50bda12748 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -88,6 +88,7 @@ "./lib/platform/utils/pr-body.ts", "./lib/proxy.ts", "./lib/types/branch-status.ts", + "./lib/types/errors/external-host-error.ts", "./lib/types/git.ts", "./lib/types/host-rules.ts", "./lib/types/later.d.ts", @@ -108,12 +109,15 @@ "./lib/util/http/types.ts", "./lib/util/index.ts", "./lib/util/json-writer/indentation-type.ts", + "./lib/util/mask.spec.ts", + "./lib/util/mask.ts", "./lib/util/object.ts", "./lib/util/sanitize.ts", "./lib/util/split.ts", "./lib/workers/pr/changelog/hbs-template.ts", "./lib/workers/pr/changelog/types.ts", "./lib/workers/repository/init/types.ts", + "./test/graphql-snapshot.ts", "./test/json-schema.ts", "./test/newline-snapshot-serializer.ts", "./test/static-files.spec.ts", -- GitLab