Skip to content

Autocomplete bug on vscode when using action in prepare/reducer format  #680

Closed
@LoiKos

Description

@LoiKos

I get an issue with vscode autocomplete when using slice with actions in reducer/prepare format.

const todosSlice = createSlice({
...
  reducers: {
    addTodo: {
      reducer(state, action) {
        const { id, text } = action.payload;
        state.push({ id, text, completed: false });
      },
      prepare(text) {
        return { payload: { text, id: nextTodoId++ } };
      },
    },
    ...
  },
});

export const actions = todosSlice.actions;

I have build a small project to demonstrate.

Inside the src/features/todos you have the slice that include a "basic" function addTodo and a version with the format reducer/prepare. If you use the reducer/prepare version you shoudn't be able to access to autocomplete in other file from the folder (src/features/todos) but it just work well if you use the other version.

You still could see autocomplete with 'abc' symbols if you already use the function but that's all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions