Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/redux-actions
Advanced tools
TypeScript definitions for redux-actions
@types/redux-actions provides TypeScript definitions for the redux-actions library, which is used to create and handle actions in Redux applications more efficiently.
createAction
The createAction function allows you to create an action creator for a specific action type. In this example, an action creator for the 'INCREMENT' action type is created, which expects a payload of type number.
const increment = createAction<number>('INCREMENT');
handleAction
The handleAction function allows you to create a reducer for a specific action type. In this example, a reducer is created for the 'INCREMENT' action type, which increments the state by the action's payload.
const counter = handleAction<number, number>(increment, (state, action) => state + action.payload, 0);
combineActions
The combineActions function allows you to handle multiple action types with a single reducer. In this example, the reducer handles both 'INCREMENT' and 'RESET' action types, resetting the state to 0 when the 'RESET' action is dispatched.
const reset = createAction('RESET');
const counter = handleAction<number, number>(combineActions(increment, reset), (state, action) => action.type === 'RESET' ? 0 : state + action.payload, 0);
createActions
The createActions function allows you to create multiple action creators at once. In this example, action creators for 'INCREMENT' and 'DECREMENT' action types are created, both expecting a payload of type number.
const { increment, decrement } = createActions({
INCREMENT: (amount: number) => amount,
DECREMENT: (amount: number) => amount
});
handleActions
The handleActions function allows you to create a reducer that handles multiple action types. In this example, a reducer is created that handles both 'INCREMENT' and 'DECREMENT' action types, incrementing or decrementing the state by the action's payload.
const counter = handleActions<number>({
[increment.toString()]: (state, action) => state + action.payload,
[decrement.toString()]: (state, action) => state - action.payload
}, 0);
@types/redux provides TypeScript definitions for the redux library. It is more general than @types/redux-actions and does not include utilities for creating and handling actions, but it provides type definitions for the core Redux functionalities like createStore, combineReducers, and applyMiddleware.
@types/redux-thunk provides TypeScript definitions for the redux-thunk middleware, which allows you to write action creators that return a function instead of an action. It is useful for handling asynchronous actions in Redux applications, but it does not provide the same action creation and handling utilities as @types/redux-actions.
@types/redux-saga provides TypeScript definitions for the redux-saga library, which is used to manage side effects in Redux applications. It offers a different approach to handling asynchronous actions compared to redux-thunk and does not include the action creation and handling utilities provided by @types/redux-actions.
npm install --save @types/redux-actions
This package contains type definitions for redux-actions (https://github.com/redux-utilities/redux-actions).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redux-actions.
These definitions were written by Jack Hsu, Alex Gorbatchev, Alec Hill, Alexey Pelykh, Thiago de Andrade, and Ziyu.
FAQs
TypeScript definitions for redux-actions
We found that @types/redux-actions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.