From 239f0607db50d0e7c08613303402c0e07a61af5b Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Sun, 3 Nov 2019 17:00:00 +0000 Subject: [PATCH] Use Redux Action type --- src/scripts/actions/choices.js | 9 +++++---- src/scripts/actions/groups.js | 3 ++- src/scripts/actions/items.js | 7 ++++--- src/scripts/actions/misc.js | 10 +++++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/scripts/actions/choices.js b/src/scripts/actions/choices.js index 97e7d8c..ad22b29 100644 --- a/src/scripts/actions/choices.js +++ b/src/scripts/actions/choices.js @@ -1,4 +1,5 @@ /** + * @typedef {import('redux').Action} Action * @typedef {import('../../../types/index').Choices.Choice} Choice */ @@ -6,7 +7,7 @@ import { ACTION_TYPES } from '../constants'; /** * @argument {Choice} choice - * @returns {{ type: string } & Choice} + * @returns {Action & Choice} */ export const addChoice = ({ value, @@ -33,7 +34,7 @@ export const addChoice = ({ /** * @argument {Choice[]} results - * @returns {{ type: string, results: Choice[] }} + * @returns {Action & { results: Choice[] }} */ export const filterChoices = results => ({ type: ACTION_TYPES.FILTER_CHOICES, @@ -42,7 +43,7 @@ export const filterChoices = results => ({ /** * @argument {boolean} active - * @returns {{ type: string, active: boolean }} + * @returns {Action & { active: boolean }} */ export const activateChoices = (active = true) => ({ type: ACTION_TYPES.ACTIVATE_CHOICES, @@ -50,7 +51,7 @@ export const activateChoices = (active = true) => ({ }); /** - * @returns {{ type: string }} + * @returns {Action} */ export const clearChoices = () => ({ type: ACTION_TYPES.CLEAR_CHOICES, diff --git a/src/scripts/actions/groups.js b/src/scripts/actions/groups.js index ea6a1ce..41ac60c 100644 --- a/src/scripts/actions/groups.js +++ b/src/scripts/actions/groups.js @@ -1,12 +1,13 @@ import { ACTION_TYPES } from '../constants'; /** + * @typedef {import('redux').Action} Action * @typedef {import('../../../types/index').Choices.Group} Group */ /** * @param {Group} group - * @returns {{ type: string } & Group} + * @returns {Action & Group} */ export const addGroup = ({ value, id, active, disabled }) => ({ type: ACTION_TYPES.ADD_GROUP, diff --git a/src/scripts/actions/items.js b/src/scripts/actions/items.js index 7e477f8..b22d9dc 100644 --- a/src/scripts/actions/items.js +++ b/src/scripts/actions/items.js @@ -1,12 +1,13 @@ import { ACTION_TYPES } from '../constants'; /** + * @typedef {import('redux').Action} Action * @typedef {import('../../../types/index').Choices.Item} Item */ /** * @param {Item} item - * @returns {{ type: string } & Item} + * @returns {Action & Item} */ export const addItem = ({ value, @@ -32,7 +33,7 @@ export const addItem = ({ /** * @param {string} id * @param {string} choiceId - * @returns {{ type: string, id: string, choiceId: string }} + * @returns {Action & { id: string, choiceId: string }} */ export const removeItem = (id, choiceId) => ({ type: ACTION_TYPES.REMOVE_ITEM, @@ -43,7 +44,7 @@ export const removeItem = (id, choiceId) => ({ /** * @param {string} id * @param {boolean} highlighted - * @returns {{ type: string, id: string, highlighted: boolean }} + * @returns {Action & { id: string, highlighted: boolean }} */ export const highlightItem = (id, highlighted) => ({ type: ACTION_TYPES.HIGHLIGHT_ITEM, diff --git a/src/scripts/actions/misc.js b/src/scripts/actions/misc.js index dea4a25..e512610 100644 --- a/src/scripts/actions/misc.js +++ b/src/scripts/actions/misc.js @@ -1,5 +1,9 @@ /** - * @returns {{ type: string }} + * @typedef {import('redux').Action} Action + */ + +/** + * @returns {Action} */ export const clearAll = () => ({ type: 'CLEAR_ALL', @@ -7,7 +11,7 @@ export const clearAll = () => ({ /** * @param {any} state - * @returns {{ type: string, state: object }} + * @returns {Action & { state: object }} */ export const resetTo = state => ({ type: 'RESET_TO', @@ -16,7 +20,7 @@ export const resetTo = state => ({ /** * @param {boolean} isLoading - * @returns {{ type: string, isLoading: boolean }} + * @returns {Action & { isLoading: boolean }} */ export const setIsLoading = isLoading => ({ type: 'SET_IS_LOADING',