store icon indicating copy to clipboard operation
store copied to clipboard

2.0.0-rc.0 : Type StateContext has no property 'dispatch' and no string index signature

Open xmlking opened this issue 8 years ago • 4 comments

I am getting following compile time error with 2.0.0-rc.0

ERROR in libs/auth/src/auth.state.ts(64,43): error TS2459: Type 'StateContext<AuthStateModel>' has no property 'dispatch' and no string index signature.

I don't see dispatch method on StateContext. Am i doing anything working ?

 @Action(ChangeAuthMode)
  async changeAuthMode({ state, setState, dispatch }: StateContext<AuthStateModel>, { payload }: ChangeAuthMode) {
    if (state.authMode !== payload) {
      switch (payload) {
        case AuthMode.PasswordFlow:
          this.oauthService.configure(authConfigPassword);
          break;
        default:
          this.oauthService.configure(authConfigImplicit);
          break;
      }
      await this.oauthService.loadDiscoveryDocument();
      return dispatch(new AuthModeChanged(payload));
    }
  }

xmlking avatar Mar 18 '18 01:03 xmlking

@xmlking I THINK it is because of your switch statement. if you take that out do you still see the issue?

deebloo avatar Mar 18 '18 12:03 deebloo

I've used dispatch today but without using the StateContext type annotation.

tsawan avatar Mar 18 '18 14:03 tsawan

StateContext interface is missing dispatch https://github.com/amcdnl/ngxs/blob/master/src/symbols.ts#L13

xmlking avatar Mar 18 '18 14:03 xmlking

Fixed in rc1

amcdnl avatar Mar 18 '18 16:03 amcdnl