Skip to content

Commit

Permalink
fix: fix typing of action type and TYPE properties to properly us…
Browse files Browse the repository at this point in the history
…e literal string type
  • Loading branch information
MrWolfZ committed May 13, 2018
1 parent 6095ed2 commit 0cd07b6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## ngrx-forms Changelog

<a name="2.3.5"></a>
### 2.3.5

#### Bugfixes

* fix typing of action `type` and `TYPE` properties to properly use literal string type, closes [#75](https://github.com/MrWolfZ/ngrx-forms/issues/75), thanks @bufke for helping me find this

<a name="2.3.4"></a>
### 2.3.4

Expand Down
46 changes: 25 additions & 21 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { Action } from '@ngrx/store';
import { ValidationErrors } from '@angular/forms';
import { NgrxFormControlId, KeyValue } from './state';

// NOTE: the explicit type declaration for the `TYPE` properties is required
// for the output declarations to properly use the literal string type instead
// of just `string`

export class SetValueAction<TValue> implements Action {
static readonly TYPE = 'ngrx/forms/SET_VALUE';
static readonly TYPE: 'ngrx/forms/SET_VALUE' = 'ngrx/forms/SET_VALUE';
readonly type = SetValueAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -21,7 +25,7 @@ export class SetValueAction<TValue> implements Action {
}

export class SetErrorsAction implements Action {
static readonly TYPE = 'ngrx/forms/SET_ERRORS';
static readonly TYPE: 'ngrx/forms/SET_ERRORS' = 'ngrx/forms/SET_ERRORS';
readonly type = SetErrorsAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -41,7 +45,7 @@ export class SetErrorsAction implements Action {
}

export class SetAsyncErrorAction implements Action {
static readonly TYPE = 'ngrx/forms/SET_ASYNC_ERROR';
static readonly TYPE: 'ngrx/forms/SET_ASYNC_ERROR' = 'ngrx/forms/SET_ASYNC_ERROR';
readonly type = SetAsyncErrorAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -64,7 +68,7 @@ export class SetAsyncErrorAction implements Action {
}

export class ClearAsyncErrorAction implements Action {
static readonly TYPE = 'ngrx/forms/CLEAR_ASYNC_ERROR';
static readonly TYPE: 'ngrx/forms/CLEAR_ASYNC_ERROR' = 'ngrx/forms/CLEAR_ASYNC_ERROR';
readonly type = ClearAsyncErrorAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -84,7 +88,7 @@ export class ClearAsyncErrorAction implements Action {
}

export class StartAsyncValidationAction implements Action {
static readonly TYPE = 'ngrx/forms/START_ASYNC_VALIDATION';
static readonly TYPE: 'ngrx/forms/START_ASYNC_VALIDATION' = 'ngrx/forms/START_ASYNC_VALIDATION';
readonly type = StartAsyncValidationAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -104,7 +108,7 @@ export class StartAsyncValidationAction implements Action {
}

export class MarkAsDirtyAction implements Action {
static readonly TYPE = 'ngrx/forms/MARK_AS_DIRTY';
static readonly TYPE: 'ngrx/forms/MARK_AS_DIRTY' = 'ngrx/forms/MARK_AS_DIRTY';
readonly type = MarkAsDirtyAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -114,7 +118,7 @@ export class MarkAsDirtyAction implements Action {
}

export class MarkAsPristineAction implements Action {
static readonly TYPE = 'ngrx/forms/MARK_AS_PRISTINE';
static readonly TYPE: 'ngrx/forms/MARK_AS_PRISTINE' = 'ngrx/forms/MARK_AS_PRISTINE';
readonly type = MarkAsPristineAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -124,7 +128,7 @@ export class MarkAsPristineAction implements Action {
}

export class EnableAction implements Action {
static readonly TYPE = 'ngrx/forms/ENABLE';
static readonly TYPE: 'ngrx/forms/ENABLE' = 'ngrx/forms/ENABLE';
readonly type = EnableAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -134,7 +138,7 @@ export class EnableAction implements Action {
}

export class DisableAction implements Action {
static readonly TYPE = 'ngrx/forms/DISABLE';
static readonly TYPE: 'ngrx/forms/DISABLE' = 'ngrx/forms/DISABLE';
readonly type = DisableAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -144,7 +148,7 @@ export class DisableAction implements Action {
}

export class MarkAsTouchedAction implements Action {
static readonly TYPE = 'ngrx/forms/MARK_AS_TOUCHED';
static readonly TYPE: 'ngrx/forms/MARK_AS_TOUCHED' = 'ngrx/forms/MARK_AS_TOUCHED';
readonly type = MarkAsTouchedAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -154,7 +158,7 @@ export class MarkAsTouchedAction implements Action {
}

export class MarkAsUntouchedAction implements Action {
static readonly TYPE = 'ngrx/forms/MARK_AS_UNTOUCHED';
static readonly TYPE: 'ngrx/forms/MARK_AS_UNTOUCHED' = 'ngrx/forms/MARK_AS_UNTOUCHED';
readonly type = MarkAsUntouchedAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -164,7 +168,7 @@ export class MarkAsUntouchedAction implements Action {
}

export class FocusAction implements Action {
static readonly TYPE = 'ngrx/forms/FOCUS';
static readonly TYPE: 'ngrx/forms/FOCUS' = 'ngrx/forms/FOCUS';
readonly type = FocusAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -174,7 +178,7 @@ export class FocusAction implements Action {
}

export class UnfocusAction implements Action {
static readonly TYPE = 'ngrx/forms/UNFOCUS';
static readonly TYPE: 'ngrx/forms/UNFOCUS' = 'ngrx/forms/UNFOCUS';
readonly type = UnfocusAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -184,7 +188,7 @@ export class UnfocusAction implements Action {
}

export class MarkAsSubmittedAction implements Action {
static readonly TYPE = 'ngrx/forms/MARK_AS_SUBMITTED';
static readonly TYPE: 'ngrx/forms/MARK_AS_SUBMITTED' = 'ngrx/forms/MARK_AS_SUBMITTED';
readonly type = MarkAsSubmittedAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -194,7 +198,7 @@ export class MarkAsSubmittedAction implements Action {
}

export class MarkAsUnsubmittedAction implements Action {
static readonly TYPE = 'ngrx/forms/MARK_AS_UNSUBMITTED';
static readonly TYPE: 'ngrx/forms/MARK_AS_UNSUBMITTED' = 'ngrx/forms/MARK_AS_UNSUBMITTED';
readonly type = MarkAsUnsubmittedAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -204,7 +208,7 @@ export class MarkAsUnsubmittedAction implements Action {
}

export class AddArrayControlAction<TValue> implements Action {
static readonly TYPE = 'ngrx/forms/ADD_ARRAY_CONTROL';
static readonly TYPE: 'ngrx/forms/ADD_ARRAY_CONTROL' = 'ngrx/forms/ADD_ARRAY_CONTROL';
readonly type = AddArrayControlAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -224,7 +228,7 @@ export class AddArrayControlAction<TValue> implements Action {
}

export class AddGroupControlAction<TValue extends KeyValue, TControlKey extends keyof TValue = string> implements Action {
static readonly TYPE = 'ngrx/forms/ADD_GROUP_CONTROL';
static readonly TYPE: 'ngrx/forms/ADD_GROUP_CONTROL' = 'ngrx/forms/ADD_GROUP_CONTROL';
readonly type = AddGroupControlAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -244,7 +248,7 @@ export class AddGroupControlAction<TValue extends KeyValue, TControlKey extends
}

export class RemoveArrayControlAction implements Action {
static readonly TYPE = 'ngrx/forms/REMOVE_ARRAY_CONTROL';
static readonly TYPE: 'ngrx/forms/REMOVE_ARRAY_CONTROL' = 'ngrx/forms/REMOVE_ARRAY_CONTROL';
readonly type = RemoveArrayControlAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -262,7 +266,7 @@ export class RemoveArrayControlAction implements Action {
}

export class RemoveGroupControlAction<TValue> implements Action {
static readonly TYPE = 'ngrx/forms/REMOVE_CONTROL';
static readonly TYPE: 'ngrx/forms/REMOVE_CONTROL' = 'ngrx/forms/REMOVE_CONTROL';
readonly type = RemoveGroupControlAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -280,7 +284,7 @@ export class RemoveGroupControlAction<TValue> implements Action {
}

export class SetUserDefinedPropertyAction implements Action {
static readonly TYPE = 'ngrx/forms/SET_USER_DEFINED_PROPERTY';
static readonly TYPE: 'ngrx/forms/SET_USER_DEFINED_PROPERTY' = 'ngrx/forms/SET_USER_DEFINED_PROPERTY';
readonly type = SetUserDefinedPropertyAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand All @@ -300,7 +304,7 @@ export class SetUserDefinedPropertyAction implements Action {
}

export class ResetAction implements Action {
static readonly TYPE = 'ngrx/forms/RESET';
static readonly TYPE: 'ngrx/forms/RESET' = 'ngrx/forms/RESET';
readonly type = ResetAction.TYPE;
readonly controlId: NgrxFormControlId;

Expand Down

0 comments on commit 0cd07b6

Please sign in to comment.