ClickerMonkey / vuex-typescript-interface

Adding magical type safety to Vuex without additional code
MIT License
44 stars 4 forks source link

vuex.d.ts -> vue.d.ts #4

Closed fateevv closed 5 years ago

fateevv commented 5 years ago

It seems that the import is a bit broken. It causes type errors in a main.ts entry point when injecting a store instance into the root Vue component.

ClickerMonkey commented 5 years ago

What version of TypeScript, Vue and Vuex?

fateevv commented 5 years ago

Latest versions: TypeScript 3.4.5, Vue 2.6.10 and Vuex 3.1.1

ClickerMonkey commented 5 years ago

What is the exact error you're getting?

I'm not having any problems.

Are you importing from vuex-typescript-interface instead of vuex ?

Everywhere, or just in some places?

fateevv commented 5 years ago

I just created a new project from latest vue-cli for clean experiment. I picked Vuex, Vue-router, TypeScript (with class component syntax) and ESLint. Then I added a module to store and described it as shown in readme. The only import of Vuex is in store.ts and it is from vuex-typescript-interface. Finally I got an error when I was trying to build the project:

(property) store: Store<Root>
Argument of type '{ router: VueRouter; store: Store<Root>; render: (h: CreateElement) => VNode; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.
  Object literal may only specify known properties, and 'store' does not exist in type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.ts(2345)

My guess was that root vuex.d.ts file in your package (where augmenting of Vue is made) should be renamed to vue.d.ts as in initial vuex package.

ClickerMonkey commented 5 years ago

I have no idea how I looked at that multiple times and missed it!

I'm surprised my TypeScript didn't complain, that's a little worrying.

I've published version 1.0.1 to NPM

fateevv commented 5 years ago

Thank you, now it works! You made a very useful tool, It's a pity that I haven't found it before.

ClickerMonkey commented 5 years ago

Thanks, hopefully I'll have namespace support sometime soon!