From 0294627ec8a623fb56711e40fcd25214844f0cf0 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 5 Nov 2024 22:49:10 +0100 Subject: [PATCH] chore: wip chore: wip chore: wip --- fixtures/{wip => input}/class.ts | 15 +++++++++ fixtures/output/class.d.ts | 57 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) rename fixtures/{wip => input}/class.ts (73%) create mode 100644 fixtures/output/class.d.ts diff --git a/fixtures/wip/class.ts b/fixtures/input/class.ts similarity index 73% rename from fixtures/wip/class.ts rename to fixtures/input/class.ts index ce12b47..0a61bf4 100644 --- a/fixtures/wip/class.ts +++ b/fixtures/input/class.ts @@ -44,3 +44,18 @@ export class CustomErrorWithMethodAndTypeAndReturn { return new Error(this.message) } } + +export class Result { + constructor( + readonly value: T | null = null, + readonly error: E | null = null + ) {} + + isOk(): this is { readonly value: T } { + return this.value !== null && this.error === null; + } + + isErr(): this is { readonly error: E } { + return this.error !== null && this.value === null; + } +} diff --git a/fixtures/output/class.d.ts b/fixtures/output/class.d.ts new file mode 100644 index 0000000..1a16015 --- /dev/null +++ b/fixtures/output/class.d.ts @@ -0,0 +1,57 @@ +export declare class CustomError extends Error { + constructor( + message: string, + public readonly code: number, + public readonly metadata: Record + ) { + super(message) + this.name = 'CustomError' + } +} +export declare class CustomErrorWithMethod extends CustomError { + logError() { + console.error(`[${this.code}] ${this.message}`) + } +} +export declare class CustomErrorWithMethodAndType extends CustomError { + logError(): void { + console.error(`[${this.code}] ${this.message}`) + } + + getError(): Error { + return this + } +} +export declare class CustomErrorWithMethodAndTypeAndReturn { + constructor( + private message: string, + public readonly code: number, + public readonly metadata: Record + ) { + this.message = message + this.code = code + this.metadata = metadata + } + + logError(): void { + console.error(`[${this.code}] ${this.message}`) + } + + getError(): Error { + return new Error(this.message) + } +} +export declare class Result { + constructor( + readonly value: T | null = null, + readonly error: E | null = null + ) {} + + isOk(): this is { readonly value: T } { + return this.value !== null && this.error === null; + } + + isErr(): this is { readonly error: E } { + return this.error !== null && this.value === null; + } +} \ No newline at end of file