fix(ivy): support injection flags for provider deps without new (#30216)

Previously, we were supporting injection flags for provider deps, but only
if they fit the format `new Optional()`. This commit fixes resolution of
provider deps to also support `Optional` (without the new). This keeps us
backwards compatible with what View Engine supported.

PR Close #30216
This commit is contained in:
Kara Erickson
2019-04-30 16:41:18 -07:00
parent b15a403c71
commit b1506a3271
2 changed files with 27 additions and 5 deletions

View File

@ -145,13 +145,14 @@ export function injectArgs(types: (Type<any>| InjectionToken<any>| any[])[]): an
for (let j = 0; j < arg.length; j++) {
const meta = arg[j];
if (meta instanceof Optional || meta.ngMetadataName === 'Optional') {
if (meta instanceof Optional || meta.ngMetadataName === 'Optional' || meta === Optional) {
flags |= InjectFlags.Optional;
} else if (meta instanceof SkipSelf || meta.ngMetadataName === 'SkipSelf') {
} else if (
meta instanceof SkipSelf || meta.ngMetadataName === 'SkipSelf' || meta === SkipSelf) {
flags |= InjectFlags.SkipSelf;
} else if (meta instanceof Self || meta.ngMetadataName === 'Self') {
} else if (meta instanceof Self || meta.ngMetadataName === 'Self' || meta === Self) {
flags |= InjectFlags.Self;
} else if (meta instanceof Inject) {
} else if (meta instanceof Inject || meta === Inject) {
type = meta.token;
} else {
type = meta;