Skip to content

createComponent in TypeScript not inherit from Vue ComponentOptions #63

Closed
@TrungRueta

Description

@TrungRueta

from Vue 2.x , when use with TypeScript we always write shims file d.ts whichs support static type property used inside vue component object.
ex: in Nuxt, each component use as page need defined $options.layout = 'layout name' like this:

{
    name: 'page',
    layout: 'myLayout'
}

To typesafe this custom property, they provide d.ts:

// ComponentOptions is declared in types/options.d.ts
declare module 'vue/types/options' {
  interface ComponentOptions<V extends Vue> {
    layout?: string
  }
}

For now vue-function-api provide function createComponent to help TS's developer can inherit typesafe from package. View d.ts file i see function defined:

export declare function createComponent<PropsOptions, RawBindings>(options: ComponentOptions<PropsOptions, RawBindings>): VueProxy<PropsOptions, RawBindings>;

export interface ComponentOptions<PropsOptions = ComponentPropsOptions, RawBindings = Data, Props = ExtractPropTypes<PropsOptions>> {
    props?: PropsOptions;
    setup?: SetupFunction<Props, RawBindings>;
}

This not inherit from Vue ComponentOptions , so we lost all typesafe from shims file.

A modify d.ts code will help a lot to inherit from Vue 2.x setup env .
Thankyou!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions