feat(core): optional generic type for ElementRef (#20765)

Add optional, backwards compatible generic type to `ElementRef` to
support typed `nativeElement`

Fix #13139

PR Close #20765
This commit is contained in:
harunurhan 2017-12-03 20:17:06 +01:00 committed by Chuck Jazdzewski
parent 1ccc3242f1
commit d3d9aac4e9
2 changed files with 6 additions and 6 deletions

View File

@ -21,7 +21,7 @@
// Note: We don't expose things like `Injector`, `ViewContainer`, ... here,
// i.e. users have to ask for what they need. With that, we can build better analysis tools
// and could do better codegen in the future.
export class ElementRef {
export class ElementRef<T = any> {
/**
* The underlying native element or `null` if direct access to native elements is not supported
* (e.g. when the application runs in a web worker).
@ -43,7 +43,7 @@ export class ElementRef {
* </div>
* @stable
*/
public nativeElement: any;
public nativeElement: T;
constructor(nativeElement: any) { this.nativeElement = nativeElement; }
constructor(nativeElement: T) { this.nativeElement = nativeElement; }
}

View File

@ -362,9 +362,9 @@ export interface DoCheck {
}
/** @stable */
export declare class ElementRef {
/** @stable */ nativeElement: any;
constructor(nativeElement: any);
export declare class ElementRef<T = any> {
/** @stable */ nativeElement: T;
constructor(nativeElement: T);
}
/** @experimental */