ravenq / markdown-it-vue

The vue lib for markdown-it.
MIT License
346 stars 70 forks source link

Typscript declarations breaks markdown-it-vue #40

Open piscis opened 3 years ago

piscis commented 3 years ago

Hi

I noticed that updating markdown-it-vue from 1.1.5 to 1.1.6 + using typescript. we get the following error:

  Overload 3 of 3, '(options: ComponentOptionsWithProps<{ content: { type: (StringConstructor | NumberConstructor)[]; default: string; }; options: { type: ObjectConstructor; default: () => {}; }; }, ... 4 more ..., { ...; } & {}>): VueProxy<...>', gave the following error.
    Type 'typeof MarkdownItVue' is not assignable to type 'VueConstructor<Vue> | FunctionalComponentOptions<any, PropsDefinition<any>> | ComponentOptions<never, any, any, any, any, Record<...>> | AsyncComponentPromise<...> | AsyncComponentFactory<...>'.
      Type 'typeof MarkdownItVue' is not assignable to type 'VueConstructor<Vue>'.

I think this has something todo with:

https://github.com/ravenq/markdown-it-vue/commit/986edce61a9d29e10cff9f3442a90e7ca518fce6

piscis commented 3 years ago

It helps to typecast it to a Vue constructor but it's only a temp. workaround.

....
import Vue, { VueConstructor } from 'vue';

export default defineComponent({
  name: 'MarkdownViewer',
  components: {
    Viewer: MarkdownViewer as VueConstructor<Vue>,
  },
 ...
ggdream commented 3 years ago

It helps to typecast it to a Vue constructor but it's only a temp. workaround.

....
import Vue, { VueConstructor } from 'vue';

export default defineComponent({
  name: 'MarkdownViewer',
  components: {
    Viewer: MarkdownViewer as VueConstructor<Vue>,
  },
 ...

It's works well, thank you evey much for the reply