vueComponent / ant-design-vue

🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜
https://antdv.com/
Other
20.13k stars 3.78k forks source link

got error when using Icon.createFromIconfontCN with typescript #3474

Closed LSYUN closed 3 years ago

LSYUN commented 3 years ago

Version

2.0.0-rc.7

Environment

Vue3.0.0, typescript3.9.3

Reproduction link

https://2x.antdv.com/components/icon-cn/#components-icon-demo-use-iconfont.cn

Steps to reproduce

// my code, similar with antdv example
import { createFromIconfontCN } from '@ant-design/icons-vue';

const IconFont = createFromIconfontCN({
  scriptUrl: config.iconfontUrl
});
export default defineComponent({
  components: {
    IconFont
  }
});

// compilation 
/*
TS2769: No overload matches this call.
  The last overload gave the following error.
    Type 'Function' is not assignable to type 'Component<any, any, any, Record<string, ComputedGetter<any> | WritableComputedOptions<any>>, MethodOptions>'.
      Type 'Function' is not assignable to type 'ComponentOptions<any, any, any, Record<string, ComputedGetter<any> | WritableComputedOptions<any>>, MethodOptions, any, any, any
>'.
        Type 'Function' is not assignable to type 'ComponentOptionsBase<any, any, any, Record<string, ComputedGetter<any> | WritableComputedOptions<any>>, MethodOptions, ... 4 m
ore ..., {}>'.
          Types of property 'call' are incompatible.
            Type '(this: Function, thisArg: any, ...argArray: any[]) => any' is not assignable to type '(this: unknown, ...args: unknown[]) => never'.
              The 'this' types of each signature are incompatible.
                Type 'unknown' is not assignable to type 'Function'.

  >  99 |     IconFont,
        |     ^^^^^^^^
*/

What is expected?

fix the error

What is actually happening?

compilation fails

lhcGinv commented 3 years ago

I got this error too

tangjinzhou commented 3 years ago

临时修复

const IconFont = createFromIconfontCN({
  scriptUrl: '',
}) as any;
tangjinzhou commented 3 years ago

升级 @ant-design/icons-vue 到 5.1.9

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.