Skip to content

vue-cli新建立的项目中使用typescript,组件中使用render函数,子组件传值爆错 #4977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Wlisfes opened this issue Dec 18, 2019 · 1 comment

Comments

@Wlisfes
Copy link

Wlisfes commented Dec 18, 2019

Version

4.1.1

Reproduction link

https://github.com/Wlisfes/vuetsx

Environment info

System:
    OS: Windows 10 10.0.17763
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.13.0 - E:\AppData\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.17763.831.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.1.2
    @vue/babel-preset-app:  4.1.1
    @vue/babel-preset-jsx:  1.1.2
    @vue/babel-sugar-functional-vue:  1.1.2
    @vue/babel-sugar-inject-h:  1.1.2
    @vue/babel-sugar-v-model:  1.1.2
    @vue/babel-sugar-v-on:  1.1.2
    @vue/cli-overlay:  4.1.1
    @vue/cli-plugin-babel: ^4.1.0 => 4.1.1
    @vue/cli-plugin-router:  4.1.1
    @vue/cli-plugin-typescript: ^4.1.0 => 4.1.1
    @vue/cli-plugin-vuex:  4.1.1
    @vue/cli-service: ^4.1.0 => 4.1.1
    @vue/cli-shared-utils:  4.1.1
    @vue/component-compiler-utils:  3.1.0
    @vue/preload-webpack-plugin:  1.1.1
    @vue/web-component-wrapper:  1.2.0
    typescript: ~3.5.3 => 3.5.3
    vue: ^2.6.10 => 2.6.11
    vue-class-component: ^7.0.2 => 7.1.0
    vue-hot-reload-api:  2.3.4
    vue-loader:  15.8.3
    vue-property-decorator: ^8.3.0 => 8.3.0
    vue-router: ^3.1.3 => 3.1.3
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.10 => 2.6.11
    vue-template-es2015-compiler:  1.9.1
    vuex: ^3.1.2 => 3.1.2
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

import { Component, Vue,Prop } from 'vue-property-decorator';

@component
class Hello extends Vue {
@prop({default: '张三'})
msg!: string

render() {
return (


{this.msg}

)
}
}

@component
export default class Home extends Vue {
render() {
return (


Home


)
}
}

What is expected?

import { Component, Vue,Prop } from 'vue-property-decorator';

@component
class Hello extends Vue {
@prop({default: '张三'})
msg!: string

render() {
return (


{this.msg}

)
}
}

@component
export default class Home extends Vue {
render() {
return (


Home
<Hello
{...{
props: {
msg: '李四'
}
}}
>


)
}
}

What is actually happening?

image

No overload matches this call.
Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): Hello', gave the following error.
不能将类型“{ msg: string; }”分配给类型“ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>”。
类型“ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>”上不存在属性“msg”。
Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): Hello', gave the following error.
不能将类型“{ msg: string; }”分配给类型“ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>”。
类型“ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>”上不存在属性“msg”。
Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): Hello', gave the following error.
不能将类型“{ msg: string; }”分配给类型“ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>”。
类型“ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>”上不存在属性“msg”。ts(2769)


Hello这个组件使用{...{props}}展传值不爆错,msg=xxx class=xxx都会爆错误

@haoqunjiang
Copy link
Member

Duplicate of #2417
建议使用 https://github.com/wonderful-panda/vue-tsx-supportvue add tsx-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants