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:
parent
1ccc3242f1
commit
d3d9aac4e9
|
@ -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; }
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue