Skip to content

Issues with typing/import #635

@matthewfcarlson

Description

@matthewfcarlson

Reproduction

Getting some weird errors:



 error  in /Users/project/node_modules/pinia/dist/src/index.d.ts

ERROR in /Users/project/node_modules/pinia/dist/src/index.d.ts(7,10):
7:10 Module '"../../../../../../../../../Users/project/node_modules/pinia/dist/src/mapHelpers"' has no exported member 'mapActions'. Did you mean to use 'import mapActions from "../../../../../../../../../Users/project/node_modules/pinia/dist/src/mapHelpers"' instead?
     5 | export type { StateTree, Store, StoreDefinition, GenericStore, StoreWithGetters, GettersTree, ActionsTree, _Method, StoreWithActions, StoreWithState, StoreOnActionListener, StoreOnActionListenerContext, SubscriptionCallbackMutation, SubscriptionCallbackMutationDirect, SubscriptionCallbackMutationPatchFunction, SubscriptionCallbackMutationPatchObject, _SubscriptionCallbackMutationBase, SubscriptionCallback, PiniaCustomProperties, PiniaCustomStateProperties, DefineStoreOptions, } from './types';
     6 | export { MutationType } from './types';
  >  7 | export { mapActions, mapStores, mapState, mapWritableState, mapGetters, setMapStoreSuffix, } from './mapHelpers';
       |          ^
     8 | export type { MapStoresCustomization, _MapActionsObjectReturn, _MapActionsReturn, _MapStateObjectReturn, _MapStateReturn, _MapWritableStateObjectReturn, _MapWritableStateReturn, _Spread, _StoreObject, } from './mapHelpers';
     9 | export { createStore } from './deprecated';
    10 | //# sourceMappingURL=index.d.ts.map

 error  in /Users/project/node_modules/pinia/dist/src/index.d.ts

ERROR in /Users/project/node_modules/pinia/dist/src/index.d.ts(7,22):
7:22 Module '"../../../../../../../../../Users/project/node_modules/pinia/dist/src/mapHelpers"' has no exported member 'mapStores'. Did you mean to use 'import mapStores from "../../../../../../../../../Users/project/node_modules/pinia/dist/src/mapHelpers"' instead?
     5 | export type { StateTree, Store, StoreDefinition, GenericStore, StoreWithGetters, GettersTree, ActionsTree, _Method, StoreWithActions, StoreWithState, StoreOnActionListener, StoreOnActionListenerContext, SubscriptionCallbackMutation, SubscriptionCallbackMutationDirect, SubscriptionCallbackMutationPatchFunction, SubscriptionCallbackMutationPatchObject, _SubscriptionCallbackMutationBase, SubscriptionCallback, PiniaCustomProperties, PiniaCustomStateProperties, DefineStoreOptions, } from './types';
     6 | export { MutationType } from './types';
  >  7 | export { mapActions, mapStores, mapState, mapWritableState, mapGetters, setMapStoreSuffix, } from './mapHelpers';
       |                      ^
     8 | export type { MapStoresCustomization, _MapActionsObjectReturn, _MapActionsReturn, _MapStateObjectReturn, _MapStateReturn, _MapWritableStateObjectReturn, _MapWritableStateReturn, _Spread, _StoreObject, } from './mapHelpers';
     9 | export { createStore } from './deprecated';
    10 | //# sourceMappingURL=index.d.ts.map

 error  in /Users/project/node_modules/pinia/dist/src/index.d.ts

ERROR in /Users/project/node_modules/pinia/dist/src/index.d.ts(7,33):
7:33 Module '"../../../../../../../../../Users/project/node_modules/pinia/dist/src/mapHelpers"' has no exported member 'mapState'. Did you mean to use 'import mapState from "../../../../../../../../../Users/project/node_modules/pinia/dist/src/mapHelpers"' instead?
     5 | export type { StateTree, Store, StoreDefinition, GenericStore, StoreWithGetters, GettersTree, ActionsTree, _Method, StoreWithActions, StoreWithState, StoreOnActionListener, StoreOnActionListenerContext, SubscriptionCallbackMutation, SubscriptionCallbackMutationDirect, SubscriptionCallbackMutationPatchFunction, SubscriptionCallbackMutationPatchObject, _SubscriptionCallbackMutationBase, SubscriptionCallback, PiniaCustomProperties, PiniaCustomStateProperties, DefineStoreOptions, } from './types';
     6 | export { MutationType } from './types';
  >  7 | export { mapActions, mapStores, mapState, mapWritableState, mapGetters, setMapStoreSuffix, } from './mapHelpers';
       |                                 ^
     8 | export type { MapStoresCustomization, _MapActionsObjectReturn, _MapActionsReturn, _MapStateObjectReturn, _MapStateReturn, _MapWritableStateObjectReturn, _MapWritableStateReturn, _Spread, _StoreObject, } from './mapHelpers';
     9 | export { createStore } from './deprecated';
    10 | //# sourceMappingURL=index.d.ts.map

 error  in /Users/project/node_modules/pinia/dist/src/index.d.ts

It goes on for about 3000 lines and ends with

ERROR in /Users/project/node_modules/pinia/dist/src/types.d.ts(259,173):
259:173 Type 'G' does not satisfy the constraint 'Record<string, (() => any) | ((state: {}) => any)>'.
  Type 'Record<string, (() => any) | ((state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any)>' is not assignable to type 'Record<string, (() => any) | ((state: {}) => any)>'.
    Index signatures are incompatible.
      Type '(() => any) | ((state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any)' is not assignable to type '(() => any) | ((state: {}) => any)'.
        Type '(state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any' is not assignable to type '(() => any) | ((state: {}) => any)'.
          Type '(state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any' is not assignable to type '() => any'.
    257 |  * about the kind of store that is passed.
    258 |  */
  > 259 | export declare type GenericStore<Id extends string = string, S extends StateTree = any, G extends GettersTree<S> = GettersTree<S>, A = ActionsTree> = StoreWithState<Id, S, G, A> & UnwrapRef<S> & StoreWithGetters<G> & StoreWithActions<A> & PiniaCustomProperties<Id, S, G, A> & PiniaCustomStateProperties<S>;
        |                                                                                                                                                                             ^
    260 | /**
    261 |  * Return type of `defineStore()`. Function that allows instantiating a store.
    262 |  */

 error  in /Users/project/node_modules/pinia/dist/src/types.d.ts

ERROR in /Users/project/node_modules/pinia/dist/src/types.d.ts(315,96):
315:96 Type 'G' does not satisfy the constraint 'Record<string, (() => any) | ((state: {}) => any)>'.
  Type 'Record<string, (() => any) | ((state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any)>' is not assignable to type 'Record<string, (() => any) | ((state: {}) => any)>'.
    Index signatures are incompatible.
      Type '(() => any) | ((state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any)' is not assignable to type '(() => any) | ((state: {}) => any)'.
        Type '(state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any' is not assignable to type '(() => any) | ((state: {}) => any)'.
          Type '(state: UnwrapRef<(Record<string | number | symbol, any> extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any' is not assignable to type '() => any'.
    313 |      * Optional object of actions.
    314 |      */
  > 315 |     actions?: A & ThisType<A & UnwrapRef<StateTree extends S ? {} : S> & StoreWithState<Id, S, G, A> & StoreWithGetters<GettersTree<S> extends G ? {} : G> & PiniaCustomProperties>;
        |                                                                                                ^
    316 | }
    317 | //# sourceMappingURL=types.d.ts.map

Here's my package.json

{
"dependencies": {
    "@vue/composition-api": "^1.1.0",
    "body-parser": "^1.19.0",
    "cookie-parser": "^1.4.5",
    "core-js": "^3.6.4",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "pinia": "^0.5.4",
    "socket.io": "^4.1.3",
    "tedious": "^12.0.0",
    "vue": "^2.6.14",
    "vue-class-component": "^7.2.3",
    "vue-property-decorator": "^8.4.1",
    "vue-router": "^3.1.6",
    "vuex": "^3.1.3"
  },
  "devDependencies": {
    "@types/body-parser": "^1.16.8",
    "@types/dotenv": "^4.0.3",
    "@types/express": "^4.11.1",
    "@types/tedious": "^4.0.5",
    "@typescript-eslint/eslint-plugin": "^2.26.0",
    "@typescript-eslint/parser": "^2.26.0",
    "@vue/cli-plugin-babel": "^4.5.3",
    "@vue/cli-plugin-eslint": "^4.5.3",
    "@vue/cli-plugin-router": "^4.5.3",
    "@vue/cli-plugin-typescript": "^4.5.3",
    "@vue/cli-plugin-vuex": "~4.5.3",
    "@vue/cli-service": "^4.5.13",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-typescript": "^5.0.2",
    "concurrently": "^5.1.0",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-vue": "^7.0.0-beta.2",
    "nodemon": "^2.0.4",
    "prettier": "^1.19.1",
    "rimraf": "^3.0.2",
    "sass": "^1.26.3",
    "sass-loader": "^8.0.2",
    "ts-node": "^8.8.2",
    "typescript": "~3.8.3",
    "vue-template-compiler": "^2.6.11"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "typeRoots": ["node_modules/@types"],
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "tedious"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

Steps to reproduce the behavior

I've been playing around with different package versions and haven't found a combination that works. Any suggestions or hints on where to go next would be appreciated.

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