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.

No typing/autocomplete for store's own properties

See original GitHub issue

Reproduction

When writing a store, I noticed I’m not actually getting any type info/autocompletion for internal state/getters/actions accessed on this, however, I do get completion for imported stores. I’m not 100% sure if this is intentional or not.

Steps to reproduce the behavior

A simple example:

import { useOtherStore } from '@/stores/useOtherStore'
import { Fruit } from '@/types'

export const useSampleStore = defineStore({
  id: 'sample',
  state() {
    return { fruits: [] as Fruit[] }
  },
  getters: {
    computedFruits() {
      const otherStore = useOtherStore()
      const otherData = otherStore.someData // has typing/autocomplete
      this.fruits.push(otherData) // this.fruits is showing as "any" type
    }
  }
})

Expected behavior

Referenced state/actions/getters inside a store on this would have correct typings

Actual behavior

Internal state/actions/getters shows up as any

Additional information

  • Using the latest stable version of VSCode with Vetur
  • Pinia version: 2.0.0-alpha.10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
syropiancommented, Apr 10, 2021

No problem, I’ll try it again tomorrow, sorry for the hassle! Really loving Pinia so far 😍

1reaction
posvacommented, Apr 9, 2021

Can you provide a reproduction? The tests are passing: https://github.com/posva/pinia/blob/v2/test-dts/store.test-d.ts#L8

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grocery Stores and Supermarkets For Sale - BizBuySell
Browse 551 Grocery Stores and Supermarkets currently available for sale on BizBuySell today to find the opportunity that's right for you!
Read more >
Grocery Stores and Supermarkets For Sale - LoopNet
View 523 Grocery Stores and Supermarkets for sale on LoopNet.com. Search LoopNet for Grocery Stores and Supermarkets for sale as well as other...
Read more >
Start Your Own Retail Grocery Business | Save A Lot Licensing
There's never been a better time to start a retail grocery business. Save A Lot helps our retail partners break into the industry...
Read more >
Store Leasing Available Properties - NYCHA - NYC.gov
Available Stores for Rent. Listings marked with an * currently have an application in process. Manhattan. First Houses (Store #4)
Read more >
Investors are betting on grocery real estate
Walmart even operates its own real estate arm, Walmart Realty. Some retailers prefer not to be encumbered by non-core assets, ...
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