Skip to content

Incorrect type for AsyncComponentFactory #11990

Closed
@Esurnir

Description

@Esurnir

Version

2.6.11

Reproduction link

https://github.com/Esurnir/repro-types-vue

Steps to reproduce

clone the repo and do yarn followed by a yarn serve, open the browser.

The test case is in App.vue

What is expected?

MyComponent1 which is a correctly typed AsyncComponent should render. It contains a component property which is of type AsyncComponentPromise which is a fonction that returns a promise.

MyComponent2 which is incorrectly typed as component is of type Promise<EsModuleComponent> should not load properly.

What is actually happening?

The opposite.


This is due to this line
which checks wether component is a promise, not a function which returns a promise.

Among the two ways this could be fixed :
component could be of type Promise<Component | EsModuleComponent> instead of the maybe confusingly named AsyncComponentPromise. Or resolveAsyncComponent could have a third case where if res.component is of type Function, it should call res.component(resolve, reject) and test if -that- is a promise before failing.

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