Skip to content

Commit

Permalink
refactor(controller-utils): replace with in isNetworkType
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptodev-2s committed Feb 26, 2024
1 parent 0bd1e9d commit 181cd7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/controller-utils/src/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { isNetworkType, NetworkType } from './types';

describe('types', () => {
it('isNetworkType', () => {
// @ts-expect-error We are intentionally passing bad input.
expect(isNetworkType({})).toBe(false);
// @ts-expect-error We are intentionally passing bad input.
expect(isNetworkType(1)).toBe(false);
expect(isNetworkType('test')).toBe(false);
expect(isNetworkType('mainnet')).toBe(true);
Expand Down
6 changes: 2 additions & 4 deletions packages/controller-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ export type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];
* @param val - the value to check whether it is NetworkType or not.
* @returns boolean indicating whether or not the argument is NetworkType.
*/
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isNetworkType(val: any): val is NetworkType {
return Object.values(NetworkType).includes(val);
export function isNetworkType(val: string): val is NetworkType {
return Object.values(NetworkType).includes(val as NetworkType);
}

/**
Expand Down

0 comments on commit 181cd7e

Please sign in to comment.