Skip to content

Commit b96869a

Browse files
mheveryvikerman
authored andcommitted
refactor(Type): merge Type and ConcreType<?> into Type<?> (#10616)
Closes #9729 BREAKING CHANGE: `Type` is now `Type<T>` which means that in most cases you have to use `Type<any>` in place of `Type`. We don't expect that any user applications use the `Type` type.
1 parent 6f4ee61 commit b96869a

File tree

91 files changed

+636
-713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+636
-713
lines changed

modules/@angular/common/src/common_directives.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Type} from '@angular/core';
9+
import {Provider} from '@angular/core';
1010

1111
import {CORE_DIRECTIVES} from './directives';
1212

@@ -55,4 +55,4 @@ import {CORE_DIRECTIVES} from './directives';
5555
*
5656
* @experimental Contains forms which are experimental.
5757
*/
58-
export const COMMON_DIRECTIVES: Type[][] = [CORE_DIRECTIVES];
58+
export const COMMON_DIRECTIVES: any[] = CORE_DIRECTIVES;

modules/@angular/common/src/directives/core_directives.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Type} from '../facade/lang';
9+
import {Type} from '@angular/core';
1010

1111
import {NgClass} from './ng_class';
1212
import {NgFor} from './ng_for';
@@ -58,7 +58,7 @@ import {NgTemplateOutlet} from './ng_template_outlet';
5858
*
5959
* @stable
6060
*/
61-
export const CORE_DIRECTIVES: Type[] = [
61+
export const CORE_DIRECTIVES: Type<any>[] = [
6262
NgClass,
6363
NgFor,
6464
NgIf,

modules/@angular/common/src/forms-deprecated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './forms-deprecated
5757
*
5858
* @experimental
5959
*/
60-
export const FORM_PROVIDERS: Type[] = [FormBuilder, RadioControlRegistry];
60+
export const FORM_PROVIDERS: Type<any>[] = [FormBuilder, RadioControlRegistry];
6161

6262

6363
/**

modules/@angular/common/src/forms-deprecated/directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export {MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValida
5858
* ```
5959
* @experimental
6060
*/
61-
export const FORM_DIRECTIVES: Type[] = [
61+
export const FORM_DIRECTIVES: Type<any>[] = [
6262
NgControlName,
6363
NgControlGroup,
6464

modules/@angular/common/src/pipes/invalid_pipe_argument_exception.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {BaseException} from '@angular/core';
10-
import {Type, stringify} from '../facade/lang';
9+
import {BaseException, Type} from '@angular/core';
10+
import {stringify} from '../facade/lang';
1111

1212
export class InvalidPipeArgumentException extends BaseException {
13-
constructor(type: Type, value: Object) {
13+
constructor(type: Type<any>, value: Object) {
1414
super(`Invalid argument '${value}' for pipe '${stringify(type)}'`);
1515
}
1616
}

modules/@angular/common/src/pipes/number_pipe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Pipe, PipeTransform} from '@angular/core';
9+
import {Pipe, PipeTransform, Type} from '@angular/core';
1010

1111
import {NumberFormatStyle, NumberFormatter} from '../facade/intl';
12-
import {NumberWrapper, Type, isBlank, isNumber, isPresent, isString} from '../facade/lang';
12+
import {NumberWrapper, isBlank, isNumber, isPresent, isString} from '../facade/lang';
1313

1414
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
1515

1616
var defaultLocale: string = 'en-US';
1717
const _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$/;
1818

1919
function formatNumber(
20-
pipe: Type, value: number | string, style: NumberFormatStyle, digits: string,
20+
pipe: Type<any>, value: number | string, style: NumberFormatStyle, digits: string,
2121
currency: string = null, currencyAsSymbol: boolean = false): string {
2222
if (isBlank(value)) return null;
2323
// Convert strings to numbers

modules/@angular/compiler/src/compile_metadata.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ChangeDetectionStrategy, SchemaMetadata, ViewEncapsulation} from '@angular/core';
9+
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
1010

1111
import {LifecycleHooks, reflector} from '../core_private';
12+
1213
import {ListWrapper, StringMapWrapper} from './facade/collection';
1314
import {BaseException, unimplemented} from './facade/exceptions';
14-
import {Type, isBlank, isPresent, isStringMap, normalizeBlank, normalizeBool} from './facade/lang';
15-
15+
import {isBlank, isPresent, isStringMap, normalizeBlank, normalizeBool} from './facade/lang';
1616
import {CssSelector} from './selector';
1717
import {getUrlScheme} from './url_resolver';
1818
import {sanitizeIdentifier, splitAtColon} from './util';
@@ -308,7 +308,7 @@ export class CompileTypeMetadata extends CompileIdentifierMetadata {
308308
lifecycleHooks: LifecycleHooks[];
309309

310310
constructor({runtime, name, moduleUrl, prefix, isHost, value, diDeps, lifecycleHooks}: {
311-
runtime?: Type,
311+
runtime?: Type<any>,
312312
name?: string,
313313
moduleUrl?: string,
314314
prefix?: string,
@@ -685,8 +685,8 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier {
685685
}
686686

687687
export class TransitiveCompileNgModuleMetadata {
688-
directivesSet = new Set<Type>();
689-
pipesSet = new Set<Type>();
688+
directivesSet = new Set<Type<any>>();
689+
pipesSet = new Set<Type<any>>();
690690
constructor(
691691
public modules: CompileNgModuleMetadata[], public providers: CompileProviderMetadata[],
692692
public entryComponents: CompileTypeMetadata[], public directives: CompileDirectiveMetadata[],

modules/@angular/compiler/src/compiler.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const _NO_XHR: XHR = {
5252
* A set of providers that provide `RuntimeCompiler` and its dependencies to use for
5353
* template compilation.
5454
*/
55-
export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> = [
55+
export const COMPILER_PROVIDERS: Array<any|Type<any>|{[k: string]: any}|any[]> = [
5656
{provide: Reflector, useValue: reflector},
5757
{provide: ReflectorReader, useExisting: Reflector},
5858
{provide: XHR, useValue: _NO_XHR},
@@ -79,8 +79,11 @@ export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> = [
7979
];
8080

8181

82-
export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[] = []):
83-
{compilerOptions: CompilerOptions, moduleDeclarations: Type[], deprecationMessages: string[]} {
82+
export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[] = []): {
83+
compilerOptions: CompilerOptions,
84+
moduleDeclarations: Type<any>[],
85+
deprecationMessages: string[]
86+
} {
8487
let platformDirectives: any[] = [];
8588
let platformPipes: any[] = [];
8689

modules/@angular/compiler/src/directive_resolver.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {BaseException, ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, resolveForwardRef} from '@angular/core';
10-
9+
import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, Type, resolveForwardRef} from '@angular/core';
1110
import {ReflectorReader, reflector} from '../core_private';
12-
1311
import {StringMapWrapper} from './facade/collection';
14-
import {Type, isPresent, stringify} from './facade/lang';
12+
import {BaseException} from './facade/exceptions';
13+
import {isPresent, stringify} from './facade/lang';
1514
import {splitAtColon} from './util';
1615

1716
function _isDirectiveMetadata(type: any): type is DirectiveMetadata {
@@ -32,7 +31,7 @@ export class DirectiveResolver {
3231
/**
3332
* Return {@link DirectiveMetadata} for a given `Type`.
3433
*/
35-
resolve(type: Type, throwIfNotFound = true): DirectiveMetadata {
34+
resolve(type: Type<any>, throwIfNotFound = true): DirectiveMetadata {
3635
var typeMetadata = this._reflector.annotations(resolveForwardRef(type));
3736
if (isPresent(typeMetadata)) {
3837
var metadata = typeMetadata.find(_isDirectiveMetadata);
@@ -49,7 +48,7 @@ export class DirectiveResolver {
4948

5049
private _mergeWithPropertyMetadata(
5150
dm: DirectiveMetadata, propertyMetadata: {[key: string]: any[]},
52-
directiveType: Type): DirectiveMetadata {
51+
directiveType: Type<any>): DirectiveMetadata {
5352
var inputs: string[] = [];
5453
var outputs: string[] = [];
5554
var host: {[key: string]: string} = {};
@@ -90,7 +89,7 @@ export class DirectiveResolver {
9089

9190
private _merge(
9291
dm: DirectiveMetadata, inputs: string[], outputs: string[], host: {[key: string]: string},
93-
queries: {[key: string]: any}, directiveType: Type): DirectiveMetadata {
92+
queries: {[key: string]: any}, directiveType: Type<any>): DirectiveMetadata {
9493
let mergedInputs: string[];
9594

9695
if (isPresent(dm.inputs)) {

modules/@angular/compiler/src/lifecycle_reflector.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit} from '@angular/core';
9+
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit, Type} from '@angular/core';
1010

1111
import {LifecycleHooks, reflector} from '../core_private';
1212

1313
import {MapWrapper} from './facade/collection';
14-
import {Type} from './facade/lang';
1514

16-
const LIFECYCLE_INTERFACES: Map<any, Type> = MapWrapper.createFromPairs([
15+
const LIFECYCLE_INTERFACES: Map<any, Type<any>> = MapWrapper.createFromPairs([
1716
[LifecycleHooks.OnInit, OnInit],
1817
[LifecycleHooks.OnDestroy, OnDestroy],
1918
[LifecycleHooks.DoCheck, DoCheck],

0 commit comments

Comments
 (0)