Skip to content

Commit 5282684

Browse files
committed
Workaround TypeScript literal type widening bug
microsoft/TypeScript#15881
1 parent 25f83d5 commit 5282684

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ export const ErrorResponseTypes = Enum(
5959
);
6060

6161
export class APIErrorResponseErrorResponse {
62-
readonly type = ErrorResponseTypes.APIErrorResponse;
62+
// Literal type annotation required due to bug whereby literal types are
63+
// lost in declarations.
64+
// https://github.com/Microsoft/TypeScript/issues/15881
65+
readonly type: typeof ErrorResponseTypes.APIErrorResponse = ErrorResponseTypes.APIErrorResponse;
6366

6467
constructor(
6568
public statusCode: number,
@@ -68,7 +71,11 @@ export class APIErrorResponseErrorResponse {
6871
}
6972

7073
export class ValidationErrorsErrorResponse {
71-
readonly type = ErrorResponseTypes.ValidationErrorsError;
74+
// Literal type annotation required due to bug whereby literal types are
75+
// lost in declarations.
76+
// https://github.com/Microsoft/TypeScript/issues/15881
77+
// tslint:disable-next-line max-line-length
78+
readonly type: typeof ErrorResponseTypes.ValidationErrorsError = ErrorResponseTypes.ValidationErrorsError;
7279

7380
constructor(
7481
public statusCode: number,

0 commit comments

Comments
 (0)