Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

299
Vistas
Converting Javascript to Typescript useReducer hook

I'm having issues converting a line of code to Typescript which I'm trying to learn. I'm getting some error lines related to my useReducer hook. I've commented out the lines above and under the issues with the error message I'm receiving.

const ACTIONS = {
    ADD_DIGIT: "add-digit",
    CLEAR: "clear",
    DELETE_DIGIT: "delete-digit",
    CHOOSE_OPERATION: "choose-operation",
    EVALUATE: "evaluate",
};
//                            Binding element 'type' implicitly has an 'any' type.
const reducer = (state: any, { type, payload }) => {
    //                           ^^ERROR
    switch (type) {
        case ACTIONS.ADD_DIGIT:
            return {
                ...state,

                //               ##Cannot find name 'currentOperand'
                currentOperand: `${currentOperand || ""}${payload.digit}`,
                //                  ^^ERROR
            };
    }
};

const App: React.FC = () => {
    const [{ currentOperand, previousOperand, operation }, dispatch] = useReducer(
        reducer,
        {}
    );

    dispatch({ type: ACTIONS.ADD_DIGIT, payload: { digit: 1 } });

    return ()

}

over 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Asistente virtual