"Fossies" - the Fresh Open Source Software Archive

Member "vue-2.6.14/types/test/async-component-test.ts" (7 Jun 2021, 933 Bytes) of package /linux/www/vue-2.6.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import Vue, { AsyncComponent, Component } from "../index";
    2 
    3 const a: AsyncComponent = () => ({
    4   component: new Promise<Component>((res, rej) => {
    5     res({ template: "" })
    6   })
    7 })
    8 
    9 const b: AsyncComponent = () => ({
   10   // @ts-expect-error component has to be a Promise that resolves to a component
   11   component: () =>
   12     new Promise<Component>((res, rej) => {
   13       res({ template: "" })
   14     })
   15 })
   16 
   17 const c: AsyncComponent = () =>
   18   new Promise<Component>((res, rej) => {
   19     res({
   20       template: ""
   21     })
   22   })
   23 
   24 const d: AsyncComponent = () =>
   25   new Promise<{ default: Component }>((res, rej) => {
   26     res({
   27       default: {
   28         template: ""
   29       }
   30     })
   31   })
   32 
   33 const e: AsyncComponent = () => ({
   34   component: new Promise<{ default: Component }>((res, rej) => {
   35     res({
   36       default: {
   37         template: ""
   38       }
   39     })
   40   })
   41 })
   42 
   43 // Test that Vue.component accepts any AsyncComponent
   44 Vue.component("async-compponent1", a)