0

I can define types for destructured function arguments in TypeScript:

import { state, myAction } from "store/types";

type Args = {
  state: state;
  action: myAction;
};

const move = ({ state, action }: Args) => {

However can you specify the types inline? So something like:

const move = ({ state: state, actionL: actionMoveExerciseUp }) => {

1 Answer 1

1

Then you will need to do this:

const move = ({ state, action }: { state: state, action: myAction }) => {
    // More logic here
}

This is because your original code is actually simply reassigning the value to another variable. ({ state: state, action: actionMoveExerciseUp }) means that the value of action will be accessible as actionmoveExercuseUp inside the scope of the arrow function instead of action.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.