Skip to content

Commit

Permalink
fix: types compatible with nuxt-property-decorator (#72)
Browse files Browse the repository at this point in the history
No more type errors for forced color mode on nuxt-property-decorator
```
import { Component } from 'nuxt-property-decorator'
import Vue from 'vue'
@component({
  colorMode: 'light',
  ...
})
export default class LightModeForcedPage extends Vue {
 ...
}
```

Given error before this fix:
```
 Overload 1 of 2, '(options: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>): <VC extends VueClass<...>>(target: VC) => VC', gave the following error.
    Argument of type '{ colorMode: string; layout: string; components: { ValidationObserver: ExtendedVue<Vue & { $_veeObserver: VeeObserver; $vnode: VNodeWithVeeContext; }, { ...; }, { ...; }, unknown, { ...; }>; ValidationProvider: ExtendedVue<...>; DatePicker: any; }; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>'.
      Object literal may only specify known properties, and 'colorMode' does not exist in type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>'.
```
  • Loading branch information
Kolahzary authored Mar 3, 2021
1 parent 7234033 commit 43f5806
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ declare module 'vue/types/vue' {
$colorMode: ColorModeInstance
}
}

declare module 'vue/types/options' {
interface ComponentOptions<V extends Vue> {
/**
* Forces a color mode for current page
* @see https://color-mode.nuxtjs.org/#force-a-color-mode
*/
colorMode?: string
}
}


0 comments on commit 43f5806

Please sign in to comment.