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

Typescript declaration not working with render function #6921

Closed
jiayexie opened this issue Oct 26, 2017 · 2 comments
Closed

Typescript declaration not working with render function #6921

jiayexie opened this issue Oct 26, 2017 · 2 comments
Assignees

Comments

@jiayexie
Copy link

jiayexie commented Oct 26, 2017

Version

2.5.2

Reproduction link

https://github.com/jiayexie/vue-typescript-declaration-repro

Steps to reproduce

  1. Build the project with npm run build. Build should pass.
    image

  2. Uncomment the render function in error.ts and build again. Build fails because component type has changed and only has a 'message' prop on it.
    image

What is expected?

Component type should be inferred from data, props, computed, methods, and be accessible in methods and render functions.

What is actually happening?

As soon as I add a render function, the type inference loses everything except props.

@jiayexie jiayexie changed the title Typescript declaration not entirely working Typescript declaration not working with render function Oct 26, 2017
@ktsn
Copy link
Member

ktsn commented Oct 26, 2017

This is because this type inference goes cyclic. Adding VNode return type to your render function would fix the problem.

import Vue, { VNode } from 'vue'

Vue.extend({
  // ...
  render(h): VNode {
    return h('div', this.message)
  }
})

We will include this caveats in the docs.

@HerringtonDarkholme
Copy link
Member

I will make a pull request to vuejs.org.

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

3 participants