Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
chore: wip

chore: wip
  • Loading branch information
chrisbbreuer committed Nov 5, 2024
1 parent 8655dca commit 0294627
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fixtures/wip/class.ts → fixtures/input/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,18 @@ export class CustomErrorWithMethodAndTypeAndReturn {
return new Error(this.message)
}
}

export class Result<T, E extends Error> {
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;
}
}
57 changes: 57 additions & 0 deletions fixtures/output/class.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export declare class CustomError extends Error {
constructor(
message: string,
public readonly code: number,
public readonly metadata: Record<string, unknown>
) {
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<string, unknown>
) {
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<T, E extends Error> {
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;
}
}

0 comments on commit 0294627

Please sign in to comment.