chore: use satisfies where applicable (#8884)

* chore: use satisfies where applicable

* chore: remove unneeded eslint ignores

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Suneet Tipirneni
2022-12-15 21:12:38 -05:00
committed by GitHub
parent 7a5134459c
commit 273ba45e27
5 changed files with 13 additions and 13 deletions

View File

@@ -34,7 +34,7 @@ export interface BaseBrokerOptions {
/** /**
* Default broker options * Default broker options
*/ */
export const DefaultBrokerOptions: Required<BaseBrokerOptions> = { export const DefaultBrokerOptions = {
name: randomBytes(20).toString('hex'), name: randomBytes(20).toString('hex'),
maxChunk: 10, maxChunk: 10,
blockTimeout: 5_000, blockTimeout: 5_000,
@@ -43,7 +43,7 @@ export const DefaultBrokerOptions: Required<BaseBrokerOptions> = {
return Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength); return Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength);
}, },
decode: (data): unknown => decode(data), decode: (data): unknown => decode(data),
}; } as const satisfies Required<BaseBrokerOptions>;
export type ToEventMap< export type ToEventMap<
TRecord extends Record<string, any>, TRecord extends Record<string, any>,

View File

@@ -21,10 +21,10 @@ export interface RPCRedisBrokerOptions extends RedisBrokerOptions {
/** /**
* Default values used for the {@link RPCRedisBrokerOptions} * Default values used for the {@link RPCRedisBrokerOptions}
*/ */
export const DefaultRPCRedisBrokerOptions: Required<Omit<RPCRedisBrokerOptions, 'redisClient'>> = { export const DefaultRPCRedisBrokerOptions = {
...DefaultBrokerOptions, ...DefaultBrokerOptions,
timeout: 5_000, timeout: 5_000,
}; } as const satisfies Required<Omit<RPCRedisBrokerOptions, 'redisClient'>>;
/** /**
* RPC broker powered by Redis * RPC broker powered by Redis

View File

@@ -415,7 +415,7 @@ export const TimestampStyles = {
* Relative time format, consisting of a relative duration format, e.g. 2 months ago * Relative time format, consisting of a relative duration format, e.g. 2 months ago
*/ */
RelativeTime: 'R', RelativeTime: 'R',
} as const; } as const satisfies Record<string, string>;
/** /**
* The possible values, see {@link TimestampStyles} for more information * The possible values, see {@link TimestampStyles} for more information

View File

@@ -5,7 +5,7 @@ import type { RESTOptions } from '../REST.js';
export const DefaultUserAgent = `DiscordBot (https://discord.js.org, [VI]{{inject}}[/VI])`; export const DefaultUserAgent = `DiscordBot (https://discord.js.org, [VI]{{inject}}[/VI])`;
export const DefaultRestOptions: Required<RESTOptions> = { export const DefaultRestOptions = {
get agent() { get agent() {
return new Agent({ return new Agent({
connect: { connect: {
@@ -28,7 +28,7 @@ export const DefaultRestOptions: Required<RESTOptions> = {
hashSweepInterval: 14_400_000, // 4 Hours hashSweepInterval: 14_400_000, // 4 Hours
hashLifetime: 86_400_000, // 24 Hours hashLifetime: 86_400_000, // 24 Hours
handlerSweepInterval: 3_600_000, // 1 Hour handlerSweepInterval: 3_600_000, // 1 Hour
}; } as const satisfies Required<RESTOptions>;
/** /**
* The events that the REST manager emits * The events that the REST manager emits
@@ -42,9 +42,9 @@ export const enum RESTEvents {
Response = 'response', Response = 'response',
} }
export const ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'] 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; 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; 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 ImageExtension = typeof ALLOWED_EXTENSIONS[number];
export type StickerExtension = typeof ALLOWED_STICKER_EXTENSIONS[number]; export type StickerExtension = typeof ALLOWED_STICKER_EXTENSIONS[number];

View File

@@ -2,7 +2,7 @@ import process from 'node:process';
import { Collection } from '@discordjs/collection'; import { Collection } from '@discordjs/collection';
import { lazy } from '@discordjs/util'; import { lazy } from '@discordjs/util';
import { APIVersion, GatewayOpcodes } from 'discord-api-types/v10'; 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'; import type { SendRateLimitState } from '../ws/WebSocketShard.js';
/** /**
@@ -26,7 +26,7 @@ const getDefaultSessionStore = lazy(() => new Collection<number, SessionInfo | n
/** /**
* Default options used by the manager * Default options used by the manager
*/ */
export const DefaultWebSocketManagerOptions: OptionalWebSocketManagerOptions = { export const DefaultWebSocketManagerOptions = {
shardCount: null, shardCount: null,
shardIds: null, shardIds: null,
largeThreshold: null, largeThreshold: null,
@@ -54,7 +54,7 @@ export const DefaultWebSocketManagerOptions: OptionalWebSocketManagerOptions = {
handshakeTimeout: 30_000, handshakeTimeout: 30_000,
helloTimeout: 60_000, helloTimeout: 60_000,
readyTimeout: 15_000, readyTimeout: 15_000,
}; } as const satisfies OptionalWebSocketManagerOptions;
export const ImportantGatewayOpcodes = new Set([ export const ImportantGatewayOpcodes = new Set([
GatewayOpcodes.Heartbeat, GatewayOpcodes.Heartbeat,