Skip to content

Commit

Permalink
chore: use satisfies where applicable (#8884)
Browse files Browse the repository at this point in the history
* chore: use satisfies where applicable

* chore: remove unneeded eslint ignores

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
suneettipirneni and kodiakhq[bot] committed Dec 16, 2022
1 parent 7a51344 commit 273ba45
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/brokers/src/brokers/Broker.ts
Expand Up @@ -34,7 +34,7 @@ export interface BaseBrokerOptions {
/**
* Default broker options
*/
export const DefaultBrokerOptions: Required<BaseBrokerOptions> = {
export const DefaultBrokerOptions = {
name: randomBytes(20).toString('hex'),
maxChunk: 10,
blockTimeout: 5_000,
Expand All @@ -43,7 +43,7 @@ export const DefaultBrokerOptions: Required<BaseBrokerOptions> = {
return Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength);
},
decode: (data): unknown => decode(data),
};
} as const satisfies Required<BaseBrokerOptions>;

export type ToEventMap<
TRecord extends Record<string, any>,
Expand Down
4 changes: 2 additions & 2 deletions packages/brokers/src/brokers/redis/RPCRedis.ts
Expand Up @@ -21,10 +21,10 @@ export interface RPCRedisBrokerOptions extends RedisBrokerOptions {
/**
* Default values used for the {@link RPCRedisBrokerOptions}
*/
export const DefaultRPCRedisBrokerOptions: Required<Omit<RPCRedisBrokerOptions, 'redisClient'>> = {
export const DefaultRPCRedisBrokerOptions = {
...DefaultBrokerOptions,
timeout: 5_000,
};
} as const satisfies Required<Omit<RPCRedisBrokerOptions, 'redisClient'>>;

/**
* RPC broker powered by Redis
Expand Down
2 changes: 1 addition & 1 deletion packages/formatters/src/formatters.ts
Expand Up @@ -415,7 +415,7 @@ export const TimestampStyles = {
* Relative time format, consisting of a relative duration format, e.g. 2 months ago
*/
RelativeTime: 'R',
} as const;
} as const satisfies Record<string, string>;

/**
* The possible values, see {@link TimestampStyles} for more information
Expand Down
10 changes: 5 additions & 5 deletions packages/rest/src/lib/utils/constants.ts
Expand Up @@ -5,7 +5,7 @@ import type { RESTOptions } from '../REST.js';

export const DefaultUserAgent = `DiscordBot (https://discord.js.org, [VI]{{inject}}[/VI])`;

export const DefaultRestOptions: Required<RESTOptions> = {
export const DefaultRestOptions = {
get agent() {
return new Agent({
connect: {
Expand All @@ -28,7 +28,7 @@ export const DefaultRestOptions: Required<RESTOptions> = {
hashSweepInterval: 14_400_000, // 4 Hours
hashLifetime: 86_400_000, // 24 Hours
handlerSweepInterval: 3_600_000, // 1 Hour
};
} as const satisfies Required<RESTOptions>;

/**
* The events that the REST manager emits
Expand All @@ -42,9 +42,9 @@ export const enum RESTEvents {
Response = 'response',
}

export const ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'] as const;
export const ALLOWED_STICKER_EXTENSIONS = ['png', 'json'] as const;
export const ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096] as const;
export const ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'] as const satisfies readonly string[];
export const ALLOWED_STICKER_EXTENSIONS = ['png', 'json'] as const satisfies readonly string[];
export const ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096] as const satisfies readonly number[];

export type ImageExtension = typeof ALLOWED_EXTENSIONS[number];
export type StickerExtension = typeof ALLOWED_STICKER_EXTENSIONS[number];
Expand Down
6 changes: 3 additions & 3 deletions packages/ws/src/utils/constants.ts
Expand Up @@ -2,7 +2,7 @@ import process from 'node:process';
import { Collection } from '@discordjs/collection';
import { lazy } from '@discordjs/util';
import { APIVersion, GatewayOpcodes } from 'discord-api-types/v10';
import type { OptionalWebSocketManagerOptions, SessionInfo } from '../ws/WebSocketManager.js';
import type { SessionInfo, OptionalWebSocketManagerOptions } from '../ws/WebSocketManager.js';
import type { SendRateLimitState } from '../ws/WebSocketShard.js';

/**
Expand All @@ -26,7 +26,7 @@ const getDefaultSessionStore = lazy(() => new Collection<number, SessionInfo | n
/**
* Default options used by the manager
*/
export const DefaultWebSocketManagerOptions: OptionalWebSocketManagerOptions = {
export const DefaultWebSocketManagerOptions = {
shardCount: null,
shardIds: null,
largeThreshold: null,
Expand Down Expand Up @@ -54,7 +54,7 @@ export const DefaultWebSocketManagerOptions: OptionalWebSocketManagerOptions = {
handshakeTimeout: 30_000,
helloTimeout: 60_000,
readyTimeout: 15_000,
};
} as const satisfies OptionalWebSocketManagerOptions;

export const ImportantGatewayOpcodes = new Set([
GatewayOpcodes.Heartbeat,
Expand Down

0 comments on commit 273ba45

Please sign in to comment.