From 5282684f7a8e445965fb18688611958870104f92 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Tue, 30 May 2017 21:08:22 +0100 Subject: [PATCH] Workaround TypeScript literal type widening bug https://github.com/Microsoft/TypeScript/issues/15881 --- src/types.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index ce2c706..b379570 100644 --- a/src/types.ts +++ b/src/types.ts @@ -59,7 +59,10 @@ export const ErrorResponseTypes = Enum( ); export class APIErrorResponseErrorResponse { - readonly type = ErrorResponseTypes.APIErrorResponse; + // Literal type annotation required due to bug whereby literal types are + // lost in declarations. + // https://github.com/Microsoft/TypeScript/issues/15881 + readonly type: typeof ErrorResponseTypes.APIErrorResponse = ErrorResponseTypes.APIErrorResponse; constructor( public statusCode: number, @@ -68,7 +71,11 @@ export class APIErrorResponseErrorResponse { } export class ValidationErrorsErrorResponse { - readonly type = ErrorResponseTypes.ValidationErrorsError; + // Literal type annotation required due to bug whereby literal types are + // lost in declarations. + // https://github.com/Microsoft/TypeScript/issues/15881 + // tslint:disable-next-line max-line-length + readonly type: typeof ErrorResponseTypes.ValidationErrorsError = ErrorResponseTypes.ValidationErrorsError; constructor( public statusCode: number,