Comments (8)
Yeah, I've got rid of the error by modifying the dist/ts-api/index.d.ts
file:
import Vue, { ComponentOptions, VueConstructor } from 'vue';
import { Context } from '../types/vue';
export declare type PropType<T> = T;
declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
declare type ComponentOptionsWithSetup<Props> = Omit<ComponentOptions<Vue>, 'props' | 'setup'> & {
props?: Props;
setup?: (this: undefined, props: {
[K in keyof Props]: Props[K];
}, context: Context) => object | null | undefined | void;
};
export declare function createComponent<Props>(compOpions: ComponentOptionsWithSetup<Props>): ComponentOptions<Vue> & VueConstructor<Vue>;
export {};
Typescript expects something like the VueConstructor
type to be rendered in JSX.
from composition-api.
This works, but now I receive an error on props saying the types are not assignable to type TsxComponentAttrs<{}, {}, {}>
from composition-api.
@IceSentry Try the v2.2.0
from composition-api.
With 2.2.0 createComponent asks for a RawBindings
type parameter if I want to pass it a Props
interface, but I do not know what it's supposed to be. Also it complains that name
isn't a valid property for ComponentOptions
. I get a bunch of really cryptic error message when trying to use a component declared with createComponent
JSX element type 'ComponentRenderProxy<ExtractPropTypes<Props, true>, { tag?: string | undefined; data?: { key?: string | number | undefined; slot?: string | undefined; scopedSlots?: { [x: string]: ScopedSlot | undefined; } | undefined; ... 17 more ...; keepAlive?: boolean | undefined; } | undefined; ... 12 more ...; isComment: boole...' is not a constructor function for JSX elements.
Type 'ComponentRenderProxy<ExtractPropTypes<Props, true>, { tag?: string | undefined; data?: { key?: string | number | undefined; slot?: string | undefined; scopedSlots?: { [x: string]: ScopedSlot | undefined; } | undefined; ... 17 more ...; keepAlive?: boolean | undefined; } | undefined; ... 12 more ...; isComment: boole...' is missing the following properties from type 'ElementClass': $el, $options, $children, $scopedSlots, and 19 more.ts(2605)
---
JSX element class does not support attributes because it does not have a '_tsxattrs' property.ts(2607)
I'm probably doing something wrong, but I don't really have time to thinker with it and figure out what's wrong. I'll give a better bug report later this week.
from composition-api.
@liximomo @IceSentry I got the same typing error when using a component created by createComponent
with 2.2.0 in JSX:
JSX element type 'ComponentRenderProxy<ExtractPropTypes<{ am: { type: StringConstructor; default: null; }; latex: { type: StringConstructor; default: null; }; display: { type: StringConstructor; default: null; }; }, true>, () => Element, ExtractPropTypes<...>>' is not a constructor function for JSX elements. Type 'ComponentRenderProxy<ExtractPropTypes<{ am: { type: StringConstructor; default: null; }; latex: { type: StringConstructor; default: null; }; display: { type: StringConstructor; default: null; }; }, true>, () => Element, ExtractPropTypes<...>>' is missing the following properties from type 'ElementClass': $el, $options, $children, $scopedSlots, and 19 more.ts(2605)
from composition-api.
At this point I believe my issue is the same as #63. Essentially, the types still needs some work.
Should I close this issue in favor of #63?
from composition-api.
The typing error shown above is actually caused by the hack given in #63 (comment). @IceSentry
Without the hack the JSX typing is all fine.
from composition-api.
I personally did not try the hack so I assumed it was related but not the same thing.
Either way, it's pretty obvious at this point that the typing for createComponent()
should somehow extend the Vue instance to be closer to the RFC. I'm not familiar enough yet with creating advanced type system with typescript to create a PR to fix this. I think I'll just wait for Vue 3 and try again at that point. The project I was trying to port to this is on hold for now anyway, so I don't even use vue at the moment.
from composition-api.
Related Issues (20)
- Bad derivation of type by `ExtractPropTypes` HOT 1
- Typing component refs HOT 2
- onMounted is called when there is no active component instance to be associated with HOT 7
- Variables created with ref in <templete>,do not automatically expand value HOT 4
- why setup run twice in vue2 HOT 8
- setup function provide a wrong prop type,when use type: Function HOT 3
- not work nice in web component, no error HOT 2
- How to avoid duplicate register composition-api ? HOT 1
- It doesn't work with nuxt 2 HOT 2
- watch 的回调如果发生错误,会一直触发调用 HOT 1
- ComponentRenderProxy类型与Vue不兼容,导致Ts编译报错 HOT 2
- vue2项目, 怎么在option API的基础上, 混用composition API? HOT 1
- render 函数中使用 web components 自定义标签,移除了HTML中原生的 slot 属性 HOT 3
- No support for Vue >= 2.7
- cdn方式引入导致vue devtools调试数据丢失 HOT 2
- 客户端使用vuecli 打包出来的commonjs模式的库,出现“Error: [vue-composition-api] must call Vue.use(VueCompositionAPI) before using any functio” HOT 2
- setup返回的data在development环境下会被expose到全局mixin的data中 HOT 2
- 是否有提供withDefaults?
- 安装时,报vue版本范围错误 HOT 2
- 【Bug】Memory Leak cause by toVue3ComponentInstance HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composition-api.