question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocomplete/intellisense/types for "actions" in defineStore() typed as "any" (missing)

See original GitHub issue

You can actually see this in the demo projects on stackblitz, when writing a func in actions, this is typed as any and doesn’t provide any autocomplete/intellisense/types

export const useCounter = defineStore({
  id: 'counter',
  state: () => ({
    n: 2,
  }),
  getters: {
    double: (state) => state.n * 2,
  },
  actions: {
    increment(amount = 1) {
      this.n += amount // this is "any", not typesafe
    },
  },
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
Bornegrimcommented, Feb 22, 2022

Try setting noImplicitThis to true in your TS config.

3reactions
realityfiltercommented, Mar 10, 2022

I was hitting this problem after refactoring a mono repo. The original package had the strict: true setting while the new one had not. Why is this necessary? I think this should be in the docs. It is hard to find the origin of this configuration error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Don't get autocomplete/intellisense when using "this" in store ...
According to the documentation I should get type support when writing "this" in store actions. Doesn't seem to work for me.
Read more >
IntelliSense in Visual Studio Code
IntelliSense. IntelliSense is a general term for various code editing features including: code completion, parameter info, quick info, and member lists.
Read more >
VSCode intellisense auto generate missing TypeScript type ...
When I create a new object: const button: Button = { // No Code Actions. } I don't have ...
Read more >
IntelliSense completion for types & extension methods
How to use IntelliSense completion for types and extension methods that you haven't imported yet with a `using` directive.
Read more >
How to type an object in Pinia state. Why unknown - r/vuejs
I have created an Interface called TeamInterface though I am unsure of how to set the type of the property to the Interface....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found