-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): async Component types (vuejs#11906)
* Update options.d.ts * Create async-component-test.ts * add generics to Component ad EsModuleComponent * remove not needed , and ; * revert unrelated changes * revert unrelated changes * revert unrelated changes * revert unrelated changes * optimize EsModuleImports * Update async-component-test.ts
- Loading branch information
Showing
2 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Vue, { AsyncComponent, Component } from "../index"; | ||
|
||
const a: AsyncComponent = () => ({ | ||
component: new Promise<Component>((res, rej) => { | ||
res({ template: "" }) | ||
}) | ||
}) | ||
|
||
const b: AsyncComponent = () => ({ | ||
// @ts-expect-error component has to be a Promise that resolves to a component | ||
component: () => | ||
new Promise<Component>((res, rej) => { | ||
res({ template: "" }) | ||
}) | ||
}) | ||
|
||
const c: AsyncComponent = () => | ||
new Promise<Component>((res, rej) => { | ||
res({ | ||
template: "" | ||
}) | ||
}) | ||
|
||
const d: AsyncComponent = () => | ||
new Promise<{ default: Component }>((res, rej) => { | ||
res({ | ||
default: { | ||
template: "" | ||
} | ||
}) | ||
}) | ||
|
||
const e: AsyncComponent = () => ({ | ||
component: new Promise<{ default: Component }>((res, rej) => { | ||
res({ | ||
default: { | ||
template: "" | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
// Test that Vue.component accepts any AsyncComponent | ||
Vue.component("async-compponent1", a) |