ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.12k stars 14.64k forks source link

[Bug Report] type checking doesn`t work #19254

Open ccforeverd opened 4 years ago

ccforeverd commented 4 years ago

Element UI version

2.13.1

OS/Browsers version

electron@8.2.3

Vue version

2.6.11

Reproduction Link

https://github.com/ccforeverd/electron-tmp3

Steps to reproduce

vue create . # with typescript
vue add electron-builder
vue add element-ui
ncu -u
yarn

update tsconfig.json

{
  "compilerOptions": {
    ...
    "types": [
      "webpack-env",
      "element-ui",
      "vuetify",
      "jest"
    ],
    "typeRoots": [
      "./node_modules/element-ui/types"
    ],
    ...
  }
}

add src/components/TestElementUI.tsx

import { Vue, Component } from 'vue-property-decorator'
import { Button } from 'element-ui'

@Component
export default class App extends Vue {
  public text = 'main-app'

  protected render (): JSX.Element {
    return (
      <main>
        <Button type="primary">{this.text}</Button>
      </main>
    )
  }
}

type yarn electron:serve

then throw error in editor and webpack output:

{
    "resource": "/Users/zhangshuyao/Sites/electron/electron-tmp3/src/components/TestElementUI.tsx",
    "owner": "typescript",
    "code": "2769",
    "severity": 8,
    "message": "No overload matches this call.\n  Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): Button', gave the following error.\n    不能将类型“{ type: string; }”分配给类型“ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>”。\n      类型“ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>”上不存在属性“type”。\n  Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): Button', gave the following error.\n    不能将类型“{ type: string; }”分配给类型“ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>”。\n      类型“ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>”上不存在属性“type”。\n  Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): Button', gave the following error.\n    不能将类型“{ type: string; }”分配给类型“ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>”。\n      类型“ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>”上不存在属性“type”。",
    "source": "ts",
    "startLineNumber": 14,
    "startColumn": 17,
    "endLineNumber": 14,
    "endColumn": 21
}

What is Expected?

no error

What is actually happening?

throw error in editor and webpack output:

{
    "resource": "/Users/zhangshuyao/Sites/electron/electron-tmp3/src/components/TestElementUI.tsx",
    "owner": "typescript",
    "code": "2769",
    "severity": 8,
    "message": "No overload matches this call.\n  Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): Button', gave the following error.\n    不能将类型“{ type: string; }”分配给类型“ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>”。\n      类型“ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>”上不存在属性“type”。\n  Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): Button', gave the following error.\n    不能将类型“{ type: string; }”分配给类型“ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>”。\n      类型“ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>”上不存在属性“type”。\n  Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): Button', gave the following error.\n    不能将类型“{ type: string; }”分配给类型“ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>”。\n      类型“ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>”上不存在属性“type”。",
    "source": "ts",
    "startLineNumber": 14,
    "startColumn": 17,
    "endLineNumber": 14,
    "endColumn": 21
}
robot-tin commented 3 years ago

+1

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.