composition-api: the `components` option in createComponent() doesn't support vue2 options
After I updated to 2.2.0, I found that when I run npm run serve, the develop server console ouput is just like this:

And I cannot run npm run build, the process will crash because of the error.
However, the browser console didn’t show any errors, and it can run normally. So I cannot simply reproduce it online… In fact, I just create the project with vue-cli3, and change App.vue to this:
<script lang="ts">
import {createComponent} from 'vue-function-api';
import HelloWorld from './components/HelloWorld.vue';
export default createComponent({
components: {HelloWorld}
});
</script>
I read the RFC again, and maybe 3.x will continue to be compatible with the 2.x components option?
And when I went back to 2.1.2, the type error disappeared. Did I go something wrong? Or how can I import and use *.vue components correctly?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 24 (10 by maintainers)
Casting
as anywill break all the types support. One of the workarounds right now is to take all the keys, except props an setup outside thecreateComponentfunction.This is already been fixed in dev branch. https://github.com/vuejs/vue-function-api/blob/703bf300308ff3a550b236cd3de461fcec9f2213/src/component/component.ts#L70-L73
Why so? By spec, its not written anywhere that
setup()and other properties cannot be used together (especiallycomponentandnamefor which I don’t see a clear alternative). There even is an example of mixed-usage wheresetup()anddataare used together.@liximomo Seems that on
@vue/composition-api0.1.,componentswork BUT not for lazy ones :Classic import
Lazy loading
I’m confused. Is the final behavior going to no longer allow
nameandcomponentsproperties within thecreateComponentfunction? This is important to know so that I can either downgrade the package for the time being or begin migrating to a newer standard.You are welcome to work on solving this challebge.
the
nameoption in createComponent() how to dealwith?Is there any other way besides setting
anytype?@liximomo