Skip to content

Commit

Permalink
Workaround TypeScript literal type widening bug
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverJAsh committed May 30, 2017
1 parent 25f83d5 commit 5282684
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 5282684

Please sign in to comment.