diff --git a/packages/core/src/di/injector.ts b/packages/core/src/di/injector.ts index 6efee5d6f7..1bcb4d66f8 100644 --- a/packages/core/src/di/injector.ts +++ b/packages/core/src/di/injector.ts @@ -230,7 +230,7 @@ function recursivelyProcessProviders(records: Map, provider: Static let scope: string|null = null; if (provider) { provider = resolveForwardRef(provider); - if (provider instanceof Array) { + if (Array.isArray(provider)) { // if we have an array recurse into the array for (let i = 0; i < provider.length; i++) { scope = recursivelyProcessProviders(records, provider[i]) || scope; @@ -359,7 +359,7 @@ function computeDeps(provider: StaticProvider): DependencyRecord[] { for (let i = 0; i < providerDeps.length; i++) { let options = OptionFlags.Default; let token = resolveForwardRef(providerDeps[i]); - if (token instanceof Array) { + if (Array.isArray(token)) { for (let j = 0, annotations = token; j < annotations.length; j++) { const annotation = annotations[j]; if (annotation instanceof Optional || annotation == Optional) { diff --git a/packages/core/src/di/injector_compatibility.ts b/packages/core/src/di/injector_compatibility.ts index 096122c0a9..e8ddaa7d33 100644 --- a/packages/core/src/di/injector_compatibility.ts +++ b/packages/core/src/di/injector_compatibility.ts @@ -227,7 +227,7 @@ export function formatError( text: string, obj: any, injectorErrorName: string, source: string | null = null): string { text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text; let context = stringify(obj); - if (obj instanceof Array) { + if (Array.isArray(obj)) { context = obj.map(stringify).join(' -> '); } else if (typeof obj === 'object') { let parts = []; diff --git a/packages/core/src/di/reflective_provider.ts b/packages/core/src/di/reflective_provider.ts index 96286d9594..11ff444555 100644 --- a/packages/core/src/di/reflective_provider.ts +++ b/packages/core/src/di/reflective_provider.ts @@ -189,7 +189,7 @@ function _normalizeProviders( } else if (b && typeof b == 'object' && (b as any).provide !== undefined) { res.push(b as NormalizedProvider); - } else if (b instanceof Array) { + } else if (Array.isArray(b)) { _normalizeProviders(b, res); } else { diff --git a/packages/core/src/util/stringify.ts b/packages/core/src/util/stringify.ts index 0af107a1f4..138ce95f62 100644 --- a/packages/core/src/util/stringify.ts +++ b/packages/core/src/util/stringify.ts @@ -11,7 +11,7 @@ export function stringify(token: any): string { return token; } - if (token instanceof Array) { + if (Array.isArray(token)) { return '[' + token.map(stringify).join(', ') + ']'; } diff --git a/packages/core/test/application_ref_spec.ts b/packages/core/test/application_ref_spec.ts index 6a4dbb83bb..d27a32a60f 100644 --- a/packages/core/test/application_ref_spec.ts +++ b/packages/core/test/application_ref_spec.ts @@ -49,7 +49,7 @@ class SomeComponent { function createModule(options: CreateModuleOptions): Type; function createModule(providersOrOptions: any[] | CreateModuleOptions | undefined): Type { let options: CreateModuleOptions = {}; - if (providersOrOptions instanceof Array) { + if (Array.isArray(providersOrOptions)) { options = {providers: providersOrOptions}; } else { options = providersOrOptions || {}; diff --git a/packages/core/testing/src/metadata_overrider.ts b/packages/core/testing/src/metadata_overrider.ts index a2c6581889..4a5bf78467 100644 --- a/packages/core/testing/src/metadata_overrider.ts +++ b/packages/core/testing/src/metadata_overrider.ts @@ -48,7 +48,7 @@ function removeMetadata(metadata: StringMap, remove: any, references: Map(); for (const prop in remove) { const removeValue = remove[prop]; - if (removeValue instanceof Array) { + if (Array.isArray(removeValue)) { removeValue.forEach( (value: any) => { removeObjects.add(_propHashKey(prop, value, references)); }); } else { @@ -58,7 +58,7 @@ function removeMetadata(metadata: StringMap, remove: any, references: Map !removeObjects.has(_propHashKey(prop, value, references))); } else { @@ -73,7 +73,7 @@ function addMetadata(metadata: StringMap, add: any) { for (const prop in add) { const addValue = add[prop]; const propValue = metadata[prop]; - if (propValue != null && propValue instanceof Array) { + if (propValue != null && Array.isArray(propValue)) { metadata[prop] = propValue.concat(addValue); } else { metadata[prop] = addValue;