Skip to content
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

Types of FunctionalComponentOptions breaks #9372

Open
meteorlxy opened this issue Jan 26, 2019 · 3 comments
Open

Types of FunctionalComponentOptions breaks #9372

meteorlxy opened this issue Jan 26, 2019 · 3 comments

Comments

@meteorlxy
Copy link
Member

meteorlxy commented Jan 26, 2019

Version

vue: 2.5.22

typescript: 3.2.4

Reproduction link

https://jsfiddle.net/meteorlxy/9x2ts16a/1/

Steps to reproduce

// works with vue 2.5.17
// fails with vue 2.5.18+
import Vue, { FunctionalComponentOptions } from 'vue'

const testFunctionalOptions: FunctionalComponentOptions = {
  functional: true,
}

Vue.component('Test', testFunctionalOptions)

What is expected?

No types error as in v2.5.17

What is actually happening?

error TS2345: Argument of type 'FunctionalComponentOptions<Record<string, any>, PropsDefinition<Record<string, any>>>' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.
  Types of property 'render' are incompatible.
    Type '(this: undefined, createElement: CreateElement, context: RenderContext<Record<string, any>>) => VNode | VNode[]' is not assignable to type '(createElement: CreateElement, hack: RenderContext<Record<string,
any>>) => VNode'.
      Type 'VNode | VNode[]' is not assignable to type 'VNode'.
        Type 'VNode[]' is missing the following properties from type 'VNode': isRootInsert, isComment

PS

It seems to be introduced here:

bf2e2ed#diff-23d7799dcc9e9be419d28a15348b0d99R116

@posva
Copy link
Member

posva commented Jan 28, 2019

As a workaround, you can give the props an explicit type:

const testFunctionalOptions: FunctionalComponentOptions<{}> = {
  functional: true,
}

@meteorlxy
Copy link
Member Author

@posva Yeah thanks

@kjleitz
Copy link

kjleitz commented Jan 29, 2019

Related to #9357

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

No branches or pull requests

4 participants