Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 1x 2x 1x 1x | import { Interface } from "./Interface"; /** * @class Class * @description A class implementing the Interface contract. * @summary This class provides an implementation of the Interface contract with additional static functionality. * It manages an internal state through a private property and offers both instance and static methods. * * @param {unknown} arg1 - First argument of unknown type * @param {string} arg2 - Second argument as string * * @implements {Interface} * * @example * ```typescript * // Create a new instance * const instance = new Class('someValue', 'stringValue'); * * // Using the generic method * await instance.method<string>() * .catch(error => console.error(error)); * * // Using the static method * Class.method(); * ``` * * @mermaid * sequenceDiagram * participant Client * participant Instance * participant Static * * Client->>Instance: new Class(arg1, arg2) * activate Instance * Instance-->>Client: class instance * deactivate Instance * * Client->>Instance: method<T>() * activate Instance * Instance-->>Client: Promise<string> * deactivate Instance * * Client->>Static: Class.method() * activate Static * Static-->>Client: void * deactivate Static */ export class Class implements Interface { /** * @description Private property to store internal state. * @summary An unknown type property used for internal state management. * @private * @type {unknown} */ private prop!: unknown; constructor(arg1: unknown, arg2: string) { console.log(arg1, arg2); } /** * @description Asynchronous method implementing the Interface contract. * @summary Throws an error with type casting chain. * * @template T The type parameter used in the error casting chain * @return {Promise<string>} A Promise that always rejects with an error * @throws {Error} Always throws an error */ async method<T>(): Promise<string> { throw new Error("error" as T as unknown as string); } /** * @description Static method that throws an error. * @summary A static utility method that always throws an error. * * @return {never} Never returns as it always throws an error * @throws {Error} Always throws an error * @static */ static method() { throw new Error("error"); } } |