Make WoltLabSuite/Core/List a proper generic class
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 18 Nov 2020 14:14:59 +0000 (15:14 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 18 Nov 2020 14:14:59 +0000 (15:14 +0100)
wcfsetup/install/files/ts/WoltLabSuite/Core/List.ts

index d09d715dbf05e3f71712319aa6819837e961b3d2..6863b5f8f8f1f3b0067cbdd6fd926c8ea009203e 100644 (file)
 import * as Core from "./Core";
 
 /** @deprecated 5.4 Use a `Set` instead. */
-class List {
-  private _set = new Set<any>();
+class List<T = any> {
+  private _set = new Set<T>();
 
   /**
    * Appends an element to the list, silently rejects adding an already existing value.
    */
-  add(value: any): void {
+  add(value: T): void {
     this._set.add(value);
   }
 
@@ -31,21 +31,21 @@ class List {
   /**
    * Removes an element from the list, returns true if the element was in the list.
    */
-  delete(value: any): boolean {
+  delete(value: T): boolean {
     return this._set.delete(value);
   }
 
   /**
    * Invokes the `callback` for each element in the list.
    */
-  forEach(callback: (value: any) => void): void {
+  forEach(callback: (value: T) => void): void {
     this._set.forEach(callback);
   }
 
   /**
    * Returns true if the list contains the element.
    */
-  has(value: any): boolean {
+  has(value: T): boolean {
     return this._set.has(value);
   }