Revert "fix(core): remove duplicated EMPTY_ARRAY constant (#40587)"

This reverts commit 34aa9c3531.
This commit is contained in:
Misko Hevery 2021-01-28 14:35:03 -08:00
parent baadd109aa
commit 88f8ddd3d3
14 changed files with 27 additions and 13 deletions

View File

@ -13,7 +13,6 @@ import {AbstractType, Type} from '../interface/type';
import {FactoryFn, getFactoryDef} from '../render3/definition_factory';
import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiProviderError} from '../render3/errors_di';
import {deepForEach, newArray} from '../util/array_utils';
import {EMPTY_ARRAY} from '../util/empty';
import {stringify} from '../util/stringify';
import {resolveForwardRef} from './forward_ref';
@ -49,6 +48,8 @@ const NOT_YET = {};
*/
const CIRCULAR = {};
const EMPTY_ARRAY = [] as any[];
/**
* A lazily initialized NullInjector.
*/

View File

@ -8,7 +8,6 @@
import {Type} from '../interface/type';
import {ReflectionCapabilities} from '../reflection/reflection_capabilities';
import {EMPTY_ARRAY} from '../util/empty';
import {getClosureSafeProperty} from '../util/property';
import {resolveForwardRef} from './forward_ref';
@ -17,6 +16,7 @@ import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, Factor
const USE_VALUE =
getClosureSafeProperty<ValueProvider>({provide: String, useValue: getClosureSafeProperty});
const EMPTY_ARRAY: any[] = [];
export function convertInjectableProviderToFactory(
type: Type<any>,

View File

@ -9,7 +9,7 @@ import '../util/ng_dev_mode';
import {assertDomNode} from '../util/assert';
import {EMPTY_ARRAY} from '../util/empty';
import {EMPTY_ARRAY} from './empty';
import {LContext, MONKEY_PATCH_KEY_NAME} from './interfaces/context';
import {TNode, TNodeFlags} from './interfaces/node';
import {RElement, RNode} from './interfaces/renderer_dom';

View File

@ -12,10 +12,9 @@ import {NgModuleDef, NgModuleType} from '../metadata/ng_module_def';
import {SchemaMetadata} from '../metadata/schema';
import {ViewEncapsulation} from '../metadata/view';
import {noSideEffects} from '../util/closure';
import {EMPTY_ARRAY} from '../util/empty';
import {initNgDevMode} from '../util/ng_dev_mode';
import {stringify} from '../util/stringify';
import {EMPTY_OBJ} from './empty';
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
import {NG_COMP_DEF, NG_DIR_DEF, NG_LOC_ID_DEF, NG_MOD_DEF, NG_PIPE_DEF} from './fields';
import {ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, DirectiveTypesOrFactory, HostBindingsFunction, PipeDef, PipeTypesOrFactory, ViewQueriesFunction} from './interfaces/definition';
import {AttributeMarker, TAttributes, TConstantsOrFactory} from './interfaces/node';

View File

@ -15,6 +15,7 @@ import {initNgDevMode} from '../util/ng_dev_mode';
*/
export const EMPTY_OBJ: {} = {};
export const EMPTY_ARRAY: any[] = [];
// freezing the values prevents any code from accidentally inserting new values in
if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
@ -22,4 +23,6 @@ if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
// when optimizing code and the whole if statement will be dropped.
// tslint:disable-next-line:no-toplevel-property-access
Object.freeze(EMPTY_OBJ);
// tslint:disable-next-line:no-toplevel-property-access
Object.freeze(EMPTY_ARRAY);
}

View File

@ -7,9 +7,8 @@
*/
import {Type, Writable} from '../../interface/type';
import {EMPTY_ARRAY} from '../../util/empty';
import {fillProperties} from '../../util/property';
import {EMPTY_OBJ} from '../empty';
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
import {ComponentDef, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, HostBindingsFunction, RenderFlags, ViewQueriesFunction} from '../interfaces/definition';
import {TAttributes} from '../interfaces/node';
import {isComponentDef} from '../interfaces/type_checks';

View File

@ -7,8 +7,8 @@
*/
import {assertDomNode, assertNumber, assertNumberInRange} from '../../util/assert';
import {EMPTY_ARRAY} from '../../util/empty';
import {assertTIcu, assertTNodeForLView} from '../assert';
import {EMPTY_ARRAY} from '../empty';
import {getCurrentICUCaseIndex} from '../i18n/i18n_util';
import {I18nRemoveOpCodes, TIcu} from '../interfaces/i18n';
import {TIcuContainerNode} from '../interfaces/node';

View File

@ -15,10 +15,9 @@ import {Query} from '../../metadata/di';
import {Component, Directive, Input} from '../../metadata/directives';
import {componentNeedsResolution, maybeQueueResolutionOfComponentResources} from '../../metadata/resource_loading';
import {ViewEncapsulation} from '../../metadata/view';
import {EMPTY_ARRAY} from '../../util/empty';
import {initNgDevMode} from '../../util/ng_dev_mode';
import {getComponentDef, getDirectiveDef} from '../definition';
import {EMPTY_OBJ} from '../empty';
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
import {NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF} from '../fields';
import {ComponentType} from '../interfaces/definition';
import {stringifyForError} from '../util/stringify_utils';

View File

@ -16,7 +16,6 @@ import {ModuleWithProviders, NgModule} from '../../metadata/ng_module';
import {NgModuleDef, NgModuleTransitiveScopes, NgModuleType} from '../../metadata/ng_module_def';
import {deepForEach, flatten} from '../../util/array_utils';
import {assertDefined} from '../../util/assert';
import {EMPTY_ARRAY} from '../../util/empty';
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
import {NG_COMP_DEF, NG_DIR_DEF, NG_MOD_DEF, NG_PIPE_DEF} from '../fields';
import {ComponentDef} from '../interfaces/definition';
@ -25,6 +24,8 @@ import {stringifyForError} from '../util/stringify_utils';
import {angularCoreEnv} from './environment';
const EMPTY_ARRAY: Type<any>[] = [];
interface ModuleQueueItem {
moduleType: Type<any>;
ngModule: NgModule;

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
export {EMPTY_ARRAY} from '../util/empty';
export {anchorDef, elementDef} from './element';
export {clearOverrides, createNgModuleFactory, overrideComponentView, overrideProvider} from './entrypoint';
export {ngContentDef} from './ng_content';
@ -17,7 +16,7 @@ export {queryDef} from './query';
export {createComponentFactory, getComponentViewDefinitionFactory, nodeValue, ViewRef_} from './refs';
export {initServicesIfNeeded} from './services';
export {textDef} from './text';
export {createRendererType2, elementEventFullName, EMPTY_MAP, inlineInterpolate, interpolate, rootRenderNodes, tokenKey, unwrapValue} from './util';
export {createRendererType2, elementEventFullName, EMPTY_ARRAY, EMPTY_MAP, inlineInterpolate, interpolate, rootRenderNodes, tokenKey, unwrapValue} from './util';
export {viewDef} from './view';
export {attachEmbeddedView, detachEmbeddedView, moveEmbeddedView} from './view_attach';

View File

@ -444,4 +444,5 @@ function _toStringWithNull(v: any): string {
return v != null ? v.toString() : '';
}
export const EMPTY_ARRAY: any[] = [];
export const EMPTY_MAP: {[key: string]: any} = {};

View File

@ -173,6 +173,12 @@
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_OBJ"
},

View File

@ -236,6 +236,9 @@
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_OBJ"
},

View File

@ -14,6 +14,9 @@
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_ARRAY"
},
{
"name": "EMPTY_OBJ"
},