vue-chartjs: [Typescript + vue-class style components] Argument of type 'typeof UsageChart' is not assignable to parameter of type 'VueClass'
Hello. I’m having an issue using the typescript sample that’s in the docs. The compiler complains about types. Any ideas how can I fix this?
The code:

Full error:
Argument of type 'typeof UsageChart' is not assignable to parameter of type 'VueClass<Vue>'. Type 'typeof UsageChart' is not assignable to type 'VueConstructor<Vue>'. Types of parameters 'options' and 'options' are incompatible. Type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>> | undefined' is not assignable to type 'ThisTypedComponentOptionsWithArrayProps<Vue, Line, object, object, never> | undefined'. Type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>' is not assignable to type 'ThisTypedComponentOptionsWithArrayProps<Vue, Line, object, object, never>'. Type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>' is not assignable to type 'ComponentOptions<Vue, DataDef<Line, Record<never, any>, Vue>, object, object, never[], Record<never, any>>'. Type 'DefaultData<Vue>' is not assignable to type 'DataDef<Line, Record<never, any>, Vue>'. Type 'object' is not assignable to type 'DataDef<Line, Record<never, any>, Vue>'. Type 'object' is not assignable to type '(this: Readonly<Record<never, any>> & Vue) => Line'. Type '{}' provides no match for the signature '(this: Readonly<Record<never, any>> & Vue): Line'.ts(2345)
Environment
- vue.js version: 2.6.8
- vue-chart.js version: 3.4.2
- npm version: 6.8.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 24
- Comments: 26 (2 by maintainers)
You should use it like this:
The solution that worked for me is to extend the vue Mixins , like in the example below.
@HoehensteigerGames in your ‘Dashboard’ class try adding
constructor() {super);}
@Djaler, for me this results in the following error:
Uncaught TypeError: Super expression must either be null or a function.The workarounds by @schnetzi and @vivss are working for now. I don’t know enough yet to suggest a proper fix though…
I tried every single solution here and I keep getting this. Why is it that Typescript is the standard at this point and yet so many libraries fail to support it properly? STEP IT UP FFS. Usually if I do the dumb hack as described here and basically not declare ‘lang=“ts”’ it’s enough but in this retarded fucking case I still get the same error. PLZ KILL ME
To work around the error I’ve written my class as follows
Only typescript solution I found:
The provided solutions are incomplete. At least with my setup I still face the following issues:
export default class MyChart extends Vue<Bar>results in a compiler warning No base constructor has the specified number of type arguments and doesn’t infer the types, so no methods/props. I could declare them myself to get rid of the warning but again, just half a solution.export default class MyChart extends Mixins(Bar)results in the same as above with a slightly different compiler warning Argument type Bar is not assignable to parameter type VueClass<unknown>export default class MyChart extends Barworks perfectly for the compiler and types are available but at runtime, it crashes with the following error:TypeError: Class extends value #<Object> is not a constructor or nullDoes any of these solutions work A-Z for you? Any ideas what may be missing?
The following worked for me too, conceptually similar, if using
vue-class-componentas opposed tovue-property-decorator(since they’re the same thing anyway).