Giter Club home page Giter Club logo

Comments (8)

skyrpex avatar skyrpex commented on April 28, 2024

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.

IceSentry avatar IceSentry commented on April 28, 2024

This works, but now I receive an error on props saying the types are not assignable to type TsxComponentAttrs<{}, {}, {}>

from composition-api.

liximomo avatar liximomo commented on April 28, 2024

@IceSentry Try the v2.2.0

from composition-api.

IceSentry avatar IceSentry commented on April 28, 2024

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.

beeplin avatar beeplin commented on April 28, 2024

@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.

IceSentry avatar IceSentry commented on April 28, 2024

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.

beeplin avatar beeplin commented on April 28, 2024

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.

IceSentry avatar IceSentry commented on April 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.