feat(common): rename underlying NgFor
class and add a type parameter (#14104)
Note, this affects the underlying class and should not affect usage. DEPRECATION: - the `NgFor` class is now deprecated. Use `NgForOf<T>` instead. IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor` directive. The `*ngFor` and related directives are unaffected by this change as references to the `NgFor` class generated from templates will be automatically converted to references to `NgForOf<T>` without requiring any template modifications. - `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead. Migration: - Replace direct references to the `NgFor` class to `NgForOf<any>`. - Replace references to `TrackByFn` to `TrackByFunction<any>`. BREAKING CHANGE: A definition of `Iterable<T>` is now required to correctly compile Angular applications. Support for `Iterable<T>` is not required at runtime but a type definition `Iterable<T>` must be available. `NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at runtime. With this change the type definition is updated to reflect this support. Migration: - add "es2015.iterable.ts" to your tsconfig.json "libs" fields. Part of #12398 PR Close #14104
This commit is contained in:

committed by
Miško Hevery

parent
69e14b500b
commit
86b2b2504f
22
tools/public_api_guard/core/index.d.ts
vendored
22
tools/public_api_guard/core/index.d.ts
vendored
@ -378,12 +378,12 @@ export declare class DebugNode {
|
||||
|
||||
/** @deprecated */
|
||||
export declare class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChanges<V> {
|
||||
collection: any;
|
||||
collection: NgIterable<V>;
|
||||
isDirty: boolean;
|
||||
length: number;
|
||||
constructor(_trackByFn?: TrackByFn);
|
||||
check(collection: V[] | Set<V>[] | any): boolean;
|
||||
diff(collection: V[] | Set<V>[] | any): DefaultIterableDiffer<V>;
|
||||
constructor(_trackByFn?: TrackByFunction<V>);
|
||||
check(collection: NgIterable<V>): boolean;
|
||||
diff(collection: NgIterable<V>): DefaultIterableDiffer<V>;
|
||||
forEachAddedItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachIdentityChange(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
forEachItem(fn: (record: IterableChangeRecord_<V>) => void): void;
|
||||
@ -556,12 +556,12 @@ export interface IterableChanges<V> {
|
||||
|
||||
/** @stable */
|
||||
export interface IterableDiffer<V> {
|
||||
diff(object: V[] | Set<V> | any): IterableChanges<V>;
|
||||
diff(object: NgIterable<V>): IterableChanges<V>;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export interface IterableDifferFactory {
|
||||
create<V>(cdRef: ChangeDetectorRef, trackByFn?: TrackByFn): IterableDiffer<V>;
|
||||
create<V>(cdRef: ChangeDetectorRef, trackByFn?: TrackByFunction<V>): IterableDiffer<V>;
|
||||
supports(objects: any): boolean;
|
||||
}
|
||||
|
||||
@ -639,6 +639,9 @@ export interface ModuleWithProviders {
|
||||
providers?: Provider[];
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare type NgIterable<T> = Array<T> | Iterable<T>;
|
||||
|
||||
/** @stable */
|
||||
export declare const NgModule: NgModuleDecorator;
|
||||
|
||||
@ -976,11 +979,16 @@ export declare class TestabilityRegistry {
|
||||
registerApplication(token: any, testability: Testability): void;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
/** @deprecated */
|
||||
export interface TrackByFn {
|
||||
(index: number, item: any): any;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export interface TrackByFunction<T> {
|
||||
(index: number, item: T): any;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare function transition(stateChangeExpr: string | ((fromState: string, toState: string) => boolean), steps: AnimationMetadata | AnimationMetadata[]): AnimationStateTransitionMetadata;
|
||||
|
||||
|
Reference in New Issue
Block a user