Typescript-react-starter: Expected 4 type arguments, but got 1.

Created on 27 Apr 2018  路  5Comments  路  Source: microsoft/TypeScript-React-Starter

I am getting this error can anyone help ?

screen shot 2018-04-27 at 19 29 06

This is the type definition of IStoreState

export interface IStoreState {
    languageName: string;
    enthusiasmLevel: number;
}

Most helpful comment

Not sure if this is the solution to it, but this worked for me

I imported EnthusiasmAction

import { EnthusiasmAction } from './actions/index';
and used like below

const store = createStore(enthusiam, {
enthusiasmLevel: 1,
languageName: 'TypeScript'
});

All 5 comments

Not sure if this is the solution to it, but this worked for me

I imported EnthusiasmAction

import { EnthusiasmAction } from './actions/index';
and used like below

const store = createStore(enthusiam, {
enthusiasmLevel: 1,
languageName: 'TypeScript'
});

If don't know what the type is, try to describe it as 'any'
const store = createStore(enthusiasm, {
enthusiasmLevel: 1,
languageName: 'TypeScript',
});

Didn't work, why it's closed and readme not updated

The solution presented by @haani104 is good, but for me was incomplete, i had to make tihis change in my /reducers/index.tsx:

import { Reducer } from "redux";

export const enthusiasm: Reducer = (
  state: StoreState,
  action: EnthusiasmAction
): StoreState => {
  switch (action.type) {
    case INCREMENT_ENTHUSIASM:
      return { ...state, enthusiasmLevel: state.enthusiasmLevel + 1 };
    case DECREMENT_ENTHUSIASM:
      return { ...state, enthusiasmLevel: state.enthusiasmLevel - 1 };
  }
  return state;
};

Basically, createStore expects a function of type Reducer as one of it arguments, and in the tutorial, we are declaring it as a plain function.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikhilyeole1 picture nikhilyeole1  路  9Comments

a455047 picture a455047  路  8Comments

painreign picture painreign  路  6Comments

JukoPowel picture JukoPowel  路  3Comments

ZeningQu picture ZeningQu  路  3Comments