markdown-it-vue icon indicating copy to clipboard operation
markdown-it-vue copied to clipboard

Typscript declarations breaks markdown-it-vue

Open piscis opened this issue 5 years ago • 2 comments

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 avatar Dec 21 '20 18:12 piscis

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>,
  },
 ...

piscis avatar Dec 21 '20 19:12 piscis

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

ggdream avatar Apr 10 '21 12:04 ggdream