fix(runtime-core/inject): handle optional from option in inject object config (#2073)

This commit is contained in:
Stanislav Lashmanov
2020-09-14 19:52:19 +03:00
committed by GitHub
parent a096a58e41
commit 313dd06065
2 changed files with 33 additions and 6 deletions

View File

@@ -275,7 +275,7 @@ type ComponentInjectOptions =
| string[]
| Record<
string | symbol,
string | symbol | { from: string | symbol; default?: unknown }
string | symbol | { from?: string | symbol; default?: unknown }
>
interface LegacyOptions<
@@ -460,7 +460,7 @@ export function applyOptions(
const opt = injectOptions[key]
if (isObject(opt)) {
ctx[key] = inject(
opt.from,
opt.from || key,
opt.default,
true /* treat default function as factory */
)