Closed lojgmyrht closed 4 years ago
Summary
Which package does this PR involve? (check one)
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
Other information: According to the docs, the correct type for the additionalPages property of a plugin's options is Array | AsyncFunction.
additionalPages
Array | AsyncFunction
Currently, code like this:
const GhostPlugin: Plugin<MyPluginOptions> = (options, context) => ({ async additionalPages(): Promise<Partial<PageOptions>[]> { const pages: Partial<PageOptions>[] = getMyPages() return pages } })
produces this error when compiling the plugin.
Type '() => Promise<Partial<PageOptions>[]>' is not assignable to type 'Partial<PageOptions>[] | Promise<Partial<PageOptions>[]> | undefined'
Passing a Promise instead of an async function produces
Promise
warning: Invalid value for "option" additionalPages: expected a Function or Array but got Promise.
when using the plugin with VuePress.
This PR enables passing an async function for additionalPages.
Nice catch! Thanks a lot ❤️
Summary
Which package does this PR involve? (check one)
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)Other information: According to the docs, the correct type for the
additionalPages
property of a plugin's options isArray | AsyncFunction
.Currently, code like this:
produces this error when compiling the plugin.
Passing a
Promise
instead of an async function produceswhen using the plugin with VuePress.
This PR enables passing an async function for
additionalPages
.