#NestJS HttpException as a TypeScript class?
3 messages · Page 1 of 1 (latest)
My Code:
export interface HttpExceptionOptions {
cause?: unknown;
description?: string;
}
static getDescriptionFrom(descriptionOrOptions: string | HttpExceptionOptions): string {
return isString(descriptionOrOptions)
? descriptionOrOptions
: descriptionOrOptions?.description;
}
Error:
Type 'string | undefined' cannot be assigned to type 'string'.
Type 'undefined' cannot be assigned to type 'string'. ts(2322)
And I wonder what I'm doing wrong, it should be compatible with the original types and the original version of the function, right?