Prefer type to interface in .d.ts files

This commit is contained in:
Evan Hahn 2022-08-30 21:24:04 +00:00 committed by GitHub
parent 9d7eaa003f
commit 39354b11b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 27 deletions

6
ts/Intl.d.ts vendored
View file

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
declare namespace Intl { declare namespace Intl {
@ -18,11 +18,11 @@ declare namespace Intl {
isWordLike?: boolean; isWordLike?: boolean;
}; };
interface Segments { type Segments = {
containing(index: number): SegmentData; containing(index: number): SegmentData;
[Symbol.iterator](): Iterator<SegmentData>; [Symbol.iterator](): Iterator<SegmentData>;
} };
// `Intl.Segmenter` is not yet in TypeScript's type definitions, so we add it. // `Intl.Segmenter` is not yet in TypeScript's type definitions, so we add it.
class Segmenter { class Segmenter {

6
ts/firstline.d.ts vendored
View file

@ -1,11 +1,11 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
declare module 'firstline' { declare module 'firstline' {
interface FirstLineOpts { type FirstLineOpts = {
encoding?: BufferEncoding; encoding?: BufferEncoding;
lineEnding?: '\n'; lineEnding?: '\n';
} };
export default function firstLine( export default function firstLine(
filePath: string, filePath: string,

28
ts/mp4box.d.ts vendored
View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
declare module 'mp4box' { declare module 'mp4box' {
interface MP4MediaTrack { type MP4MediaTrack = {
alternate_group: number; alternate_group: number;
bitrate: number; bitrate: number;
codec: string; codec: string;
@ -18,30 +18,30 @@ declare module 'mp4box' {
track_height: number; track_height: number;
track_width: number; track_width: number;
volume: number; volume: number;
} };
interface MP4VideoData { type MP4VideoData = {
height: number; height: number;
width: number; width: number;
} };
interface MP4VideoTrack extends MP4MediaTrack { type MP4VideoTrack = MP4MediaTrack & {
video: MP4VideoData; video: MP4VideoData;
} };
interface MP4AudioData { type MP4AudioData = {
channel_count: number; channel_count: number;
sample_rate: number; sample_rate: number;
sample_size: number; sample_size: number;
} };
interface MP4AudioTrack extends MP4MediaTrack { type MP4AudioTrack = MP4MediaTrack & {
audio: MP4AudioData; audio: MP4AudioData;
} };
type MP4Track = MP4VideoTrack | MP4AudioTrack; type MP4Track = MP4VideoTrack | MP4AudioTrack;
interface MP4Info { type MP4Info = {
brands: Array<string>; brands: Array<string>;
created: Date; created: Date;
duration: number; duration: number;
@ -53,16 +53,16 @@ declare module 'mp4box' {
modified: Date; modified: Date;
timescale: number; timescale: number;
tracks: Array<MP4Track>; tracks: Array<MP4Track>;
} };
export type MP4ArrayBuffer = ArrayBuffer & { fileStart: number }; export type MP4ArrayBuffer = ArrayBuffer & { fileStart: number };
export interface MP4File { export type MP4File = {
appendBuffer(data: MP4ArrayBuffer): number; appendBuffer(data: MP4ArrayBuffer): number;
flush(): void; flush(): void;
onError?: (e: string) => void; onError?: (e: string) => void;
onReady?: (info: MP4Info) => void; onReady?: (info: MP4Info) => void;
} };
export function createFile(): MP4File; export function createFile(): MP4File;
} }

View file

@ -250,7 +250,7 @@ export type CustomError = Error & {
number?: string; number?: string;
}; };
export interface CallbackResultType { export type CallbackResultType = {
successfulIdentifiers?: Array<string>; successfulIdentifiers?: Array<string>;
failoverIdentifiers?: Array<string>; failoverIdentifiers?: Array<string>;
errors?: Array<CustomError>; errors?: Array<CustomError>;
@ -268,11 +268,11 @@ export interface CallbackResultType {
recipients?: Record<string, Array<number>>; recipients?: Record<string, Array<number>>;
urgent?: boolean; urgent?: boolean;
hasPniSignatureMessage?: boolean; hasPniSignatureMessage?: boolean;
} };
export interface IRequestHandler { export type IRequestHandler = {
handleRequest(request: IncomingWebSocketRequest): void; handleRequest(request: IncomingWebSocketRequest): void;
} };
export type PniKeyMaterialType = Readonly<{ export type PniKeyMaterialType = Readonly<{
identityKeyPair: Uint8Array; identityKeyPair: Uint8Array;

View file

@ -1,4 +1,4 @@
// Copyright 2020-2021 Signal Messenger, LLC // Copyright 2020-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import type { AudioDevice } from 'ringrtc'; import type { AudioDevice } from 'ringrtc';
@ -145,7 +145,7 @@ export type StorageAccessType = {
'challenge:retry-message-ids': never; 'challenge:retry-message-ids': never;
}; };
export interface StorageInterface { export type StorageInterface = {
onready(callback: () => void): void; onready(callback: () => void): void;
get<K extends keyof StorageAccessType, V extends StorageAccessType[K]>( get<K extends keyof StorageAccessType, V extends StorageAccessType[K]>(
@ -163,4 +163,4 @@ export interface StorageInterface {
): Promise<void>; ): Promise<void>;
remove<K extends keyof StorageAccessType>(key: K): Promise<void>; remove<K extends keyof StorageAccessType>(key: K): Promise<void>;
} };