ngrx - TypeScript compiler incorrectly reports that action.payload does not exist -


i'm using ngrx 4.03 , typescript 2.5.2.

i have defined action such:

import { action } '@ngrx/store'; import { iuser } '../models';  export const login_success = '[auth] login success'; export const logout_success = '[auth] logout success';  export class loginsuccess implements action {   readonly type = login_success;    constructor (     public payload: iuser   ) {} }  export class logoutsuccess implements action {   readonly type = logout_success; }  export type authactions  = loginsuccess  | logoutsuccess; 

in corresponding reducer, typescript telling me action.payload not exist on action, though can log value fine. doing wrong?

i'm sure if have 1 action (or more) without payload, introduce behavior.

so change code:

export class logoutsuccess implements action {   readonly type = logout_success; } 

to

export class logoutsuccess implements action {   readonly type = logout_success;    constructor(public payload: null) } 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -