refactor(compiler): replace `isStaticSymbol` with `instanceof StaticSymbol`
This commit is contained in:
parent
c767df0e4e
commit
c3065aac7a
|
@ -6,10 +6,6 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function isStaticSymbol(value: any): value is StaticSymbol {
|
|
||||||
return typeof value === 'object' && value !== null && value['name'] && value['filePath'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A token representing the a reference to a static type.
|
* A token representing the a reference to a static type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {SummaryResolver} from '../summary_resolver';
|
||||||
|
|
||||||
import {GeneratedFile} from './generated_file';
|
import {GeneratedFile} from './generated_file';
|
||||||
import {StaticReflector} from './static_reflector';
|
import {StaticReflector} from './static_reflector';
|
||||||
import {StaticSymbol, isStaticSymbol} from './static_symbol';
|
import {StaticSymbol} from './static_symbol';
|
||||||
import {filterFileByPatterns} from './utils';
|
import {filterFileByPatterns} from './utils';
|
||||||
|
|
||||||
const STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
|
const STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
|
||||||
|
@ -43,7 +43,7 @@ export class AotSummaryResolver implements SummaryResolver {
|
||||||
|
|
||||||
serializeSummaries(srcFileUrl: string, summaries: CompileTypeSummary[]): GeneratedFile {
|
serializeSummaries(srcFileUrl: string, summaries: CompileTypeSummary[]): GeneratedFile {
|
||||||
const jsonReplacer = (key: string, value: any) => {
|
const jsonReplacer = (key: string, value: any) => {
|
||||||
if (key === 'reference' && isStaticSymbol(value)) {
|
if (key === 'reference' && value instanceof StaticSymbol) {
|
||||||
// We convert the source filenames into output filenames,
|
// We convert the source filenames into output filenames,
|
||||||
// as the generated summary file will be used when the current
|
// as the generated summary file will be used when the current
|
||||||
// compilation unit is used as a library
|
// compilation unit is used as a library
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
|
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
|
||||||
|
|
||||||
import {StaticSymbol, isStaticSymbol} from './aot/static_symbol';
|
import {StaticSymbol} from './aot/static_symbol';
|
||||||
import {ListWrapper} from './facade/collection';
|
import {ListWrapper} from './facade/collection';
|
||||||
import {isPresent, stringify} from './facade/lang';
|
import {isPresent, stringify} from './facade/lang';
|
||||||
import {LifecycleHooks, reflector} from './private_import_core';
|
import {LifecycleHooks, reflector} from './private_import_core';
|
||||||
|
@ -87,7 +87,7 @@ export function identifierName(compileIdentifier: CompileIdentifierMetadata): st
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const ref = compileIdentifier.reference;
|
const ref = compileIdentifier.reference;
|
||||||
if (isStaticSymbol(ref)) {
|
if (ref instanceof StaticSymbol) {
|
||||||
return ref.name;
|
return ref.name;
|
||||||
}
|
}
|
||||||
if (ref['__anonymousType']) {
|
if (ref['__anonymousType']) {
|
||||||
|
@ -106,7 +106,7 @@ export function identifierName(compileIdentifier: CompileIdentifierMetadata): st
|
||||||
|
|
||||||
export function identifierModuleUrl(compileIdentifier: CompileIdentifierMetadata): string {
|
export function identifierModuleUrl(compileIdentifier: CompileIdentifierMetadata): string {
|
||||||
const ref = compileIdentifier.reference;
|
const ref = compileIdentifier.reference;
|
||||||
if (isStaticSymbol(ref)) {
|
if (ref instanceof StaticSymbol) {
|
||||||
return ref.filePath;
|
return ref.filePath;
|
||||||
}
|
}
|
||||||
return reflector.importUri(ref);
|
return reflector.importUri(ref);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, AnimationTransitionEvent, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, LOCALE_ID, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TRANSLATIONS_FORMAT, TemplateRef, ViewContainerRef, ViewEncapsulation} from '@angular/core';
|
import {ANALYZE_FOR_ENTRY_COMPONENTS, AnimationTransitionEvent, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, LOCALE_ID, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TRANSLATIONS_FORMAT, TemplateRef, ViewContainerRef, ViewEncapsulation} from '@angular/core';
|
||||||
|
|
||||||
import {StaticSymbol, isStaticSymbol} from './aot/static_symbol';
|
import {StaticSymbol} from './aot/static_symbol';
|
||||||
import {CompileIdentifierMetadata, CompileTokenMetadata, identifierModuleUrl, identifierName} from './compile_metadata';
|
import {CompileIdentifierMetadata, CompileTokenMetadata, identifierModuleUrl, identifierName} from './compile_metadata';
|
||||||
import {AnimationGroupPlayer, AnimationKeyframe, AnimationSequencePlayer, AnimationStyles, AnimationTransition, AppView, ChangeDetectorStatus, CodegenComponentFactoryResolver, ComponentRef_, DebugAppView, DebugContext, NgModuleInjector, NoOpAnimationPlayer, StaticNodeDebugInfo, TemplateRef_, UNINITIALIZED, ValueUnwrapper, ViewContainer, ViewType, balanceAnimationKeyframes, clearStyles, collectAndResolveStyles, devModeEqual, prepareFinalAnimationStyles, reflector, registerModuleFactory, renderStyles, view_utils} from './private_import_core';
|
import {AnimationGroupPlayer, AnimationKeyframe, AnimationSequencePlayer, AnimationStyles, AnimationTransition, AppView, ChangeDetectorStatus, CodegenComponentFactoryResolver, ComponentRef_, DebugAppView, DebugContext, NgModuleInjector, NoOpAnimationPlayer, StaticNodeDebugInfo, TemplateRef_, UNINITIALIZED, ValueUnwrapper, ViewContainer, ViewType, balanceAnimationKeyframes, clearStyles, collectAndResolveStyles, devModeEqual, prepareFinalAnimationStyles, reflector, registerModuleFactory, renderStyles, view_utils} from './private_import_core';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, Directive, Host, Inject, Injectable, ModuleWithProviders, Optional, Provider, Query, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core';
|
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, Directive, Host, Inject, Injectable, ModuleWithProviders, Optional, Provider, Query, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core';
|
||||||
|
|
||||||
import {isStaticSymbol} from './aot/static_symbol';
|
import {StaticSymbol} from './aot/static_symbol';
|
||||||
import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
|
import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
|
||||||
import * as cpl from './compile_metadata';
|
import * as cpl from './compile_metadata';
|
||||||
import {DirectiveNormalizer} from './directive_normalizer';
|
import {DirectiveNormalizer} from './directive_normalizer';
|
||||||
|
@ -863,12 +863,12 @@ function flattenAndDedupeArray(tree: any[]): Array<any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidType(value: any): boolean {
|
function isValidType(value: any): boolean {
|
||||||
return isStaticSymbol(value) || (value instanceof Type);
|
return (value instanceof StaticSymbol) || (value instanceof Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function componentModuleUrl(
|
export function componentModuleUrl(
|
||||||
reflector: ReflectorReader, type: Type<any>, cmpMetadata: Component): string {
|
reflector: ReflectorReader, type: Type<any>, cmpMetadata: Component): string {
|
||||||
if (isStaticSymbol(type)) {
|
if (type instanceof StaticSymbol) {
|
||||||
return type.filePath;
|
return type.filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue