소스 검색

ref: use Prettify on some complex exported types

Sv443 5 달 전
부모
커밋
04f8009246
3개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 5 2
      lib/DataStore.ts
  2. 3 2
      lib/SelectorObserver.ts
  3. 3 3
      lib/misc.ts

+ 5 - 2
lib/DataStore.ts

@@ -1,5 +1,7 @@
 /* eslint-disable @typescript-eslint/no-explicit-any */
 
+import type { Prettify } from "./types.js";
+
 //#region types
 
 /** Function that takes the data in the old format and returns the data in the new format. Also supports an asynchronous migration. */
@@ -8,7 +10,7 @@ type MigrationFunc = (oldData: any) => any | Promise<any>;
 export type DataMigrationsDict = Record<number, MigrationFunc>;
 
 /** Options for the DataStore instance */
-export type DataStoreOptions<TData> = 
+export type DataStoreOptions<TData> = Prettify<
   & {
     /**
      * A unique internal ID for this data store.  
@@ -75,7 +77,8 @@ export type DataStoreOptions<TData> =
       encodeData?: never,
       decodeData?: never,
     }
-  );
+  )
+>;
 
 //#region class
 

+ 3 - 2
lib/SelectorObserver.ts

@@ -1,10 +1,11 @@
 import { debounce } from "./misc.js";
+import type { Prettify } from "./types.js";
 
 let domLoaded = false;
 document.addEventListener("DOMContentLoaded", () => domLoaded = true);
 
 /** Options for the `onSelector()` method of {@linkcode SelectorObserver} */
-export type SelectorListenerOptions<TElem extends Element = HTMLElement> = SelectorOptionsOne<TElem> | SelectorOptionsAll<TElem>;
+export type SelectorListenerOptions<TElem extends Element = HTMLElement> = Prettify<SelectorOptionsOne<TElem> | SelectorOptionsAll<TElem>>;
 
 type SelectorOptionsOne<TElem extends Element> = SelectorOptionsCommon & {
   /** Whether to use `querySelectorAll()` instead - default is false */
@@ -47,7 +48,7 @@ export type SelectorObserverOptions = {
   checkInterval?: number;
 };
 
-export type SelectorObserverConstructorOptions = MutationObserverInit & SelectorObserverOptions;
+export type SelectorObserverConstructorOptions = Prettify<MutationObserverInit & SelectorObserverOptions>;
 
 /** Observes the children of the given element for changes */
 export class SelectorObserver {

+ 3 - 3
lib/misc.ts

@@ -1,4 +1,4 @@
-import type { Stringifiable } from "./types.js";
+import type { Prettify, Stringifiable } from "./types.js";
 
 /**
  * Automatically appends an `s` to the passed {@linkcode word}, if {@linkcode num} is not equal to 1
@@ -63,13 +63,13 @@ export function debounce<
 }
 
 /** Options for the `fetchAdvanced()` function */
-export type FetchAdvancedOpts = Omit<
+export type FetchAdvancedOpts = Prettify<Omit<
   RequestInit & Partial<{
     /** Timeout in milliseconds after which the fetch call will be canceled with an AbortController signal */
     timeout: number;
   }>,
   "signal"
->;
+>>;
 
 /** Calls the fetch API with special options like a timeout */
 export async function fetchAdvanced(input: RequestInfo | URL, options: FetchAdvancedOpts = {}): Promise<Response> {