Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint: 'Partial' is not defined in typescript

ESLint is not recognizing Partial of typescript but the compiled module does not give any error.

const initialState: IAuthState = {
  authenticated: false,
  processing: false,
};

const authReducer = (state: IAuthState = initialState, action: any): IAuthState => {
  const State = (newState: Partial<IAuthState>): IAuthState => ({...state, ...newState});

  switch (action.type) {
    case Actions.SIGN_IN_PROCESS_INITIATED:
      return State({processing: true});

    case Actions.SIGN_IN_PROCESS_FAILED:
      return State({processing: false});

    default:
      return state;
  }
};

I know that this can be suppressed by // eslint-disable-next-line no-undef but still, I want an explanation for this and a permanent solution so that I dont get this not so error Error.

like image 948
Faisal Manzer Avatar asked Dec 21 '19 11:12

Faisal Manzer


1 Answers

I had a similar case some time ago and fixed it by installing @typescript-eslint/parser as devDependency and including it in eslint config:

  "extends": [..., "@typescript-eslint/parser"],
like image 145
winiar Avatar answered Nov 02 '22 09:11

winiar