Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
TS2339: Property 'data' does not exist

I have this angular store configuration

action.ts

    export const saveUserAction = createAction(
      '[User] Save',
      props<{ payload: User }>
    );

export const saveUserSuccessAction = createAction(
  '[User] Save Success',
  props<{ data: User }>
)

reducer.ts

export const reducer = createReducer(
  initialState,
  on(loadUsers, (state) => ({...state, isLoading: true})),
  on(UserAction.loadUsersSuccess, (state, {data: users}) => ({...state, data: users, isLoading: false})),
  on(UserAction.loadUsersFailure, (state, error) => ({...state, error: error, isLoading: false})),
  on(saveUserFailureAction, (state, error) => ({...state, isLoading: false, error: error})),
  on(saveUserSuccessAction, (state, {data: user}) => ({...state, isLoading: false, selectedUser: user})),
);

effect.ts

saveUserEffect$ = createEffect(() => this.actions$.pipe(
    ofType(saveUserAction),
    switchMap((action: ActionType<typeof saveUserAction>) => {
      return this.userService.saveUser(action.payload).pipe(
        map((user) => {
          return saveUserSuccessAction(user)
        }),
        catchError(error => observableOf(saveUserFailureAction({error: error})))
      )
    })
  ))

Typescript complains

TS2339: Property 'payload' does not exist on type 'ActionCreatorProps{ payload: User; }> & TypedAction"[User] Save"> & { type: "[User] Save"; }'  

and in the reducer on saveUserSuccessAction it complains

TS2339: Property 'data' does not exist on type 'ActionCreatorProps{ data: User; }> & TypedAction"[User] Save Success"> & { type: "[User] Save Success"; }'

it seems strong type is very difficult in java-script. I don't want to use any type

How can I make it work?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!