From d3d9aac4e93dc870d154563a9c29a7eb7c76e044 Mon Sep 17 00:00:00 2001 From: harunurhan Date: Sun, 3 Dec 2017 20:17:06 +0100 Subject: [PATCH] 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 --- packages/core/src/linker/element_ref.ts | 6 +++--- tools/public_api_guard/core/core.d.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/linker/element_ref.ts b/packages/core/src/linker/element_ref.ts index 343387ef88..e4cf8b565d 100644 --- a/packages/core/src/linker/element_ref.ts +++ b/packages/core/src/linker/element_ref.ts @@ -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 { /** * 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 { * * @stable */ - public nativeElement: any; + public nativeElement: T; - constructor(nativeElement: any) { this.nativeElement = nativeElement; } + constructor(nativeElement: T) { this.nativeElement = nativeElement; } } diff --git a/tools/public_api_guard/core/core.d.ts b/tools/public_api_guard/core/core.d.ts index 160ad71095..33ecbd89c5 100644 --- a/tools/public_api_guard/core/core.d.ts +++ b/tools/public_api_guard/core/core.d.ts @@ -362,9 +362,9 @@ export interface DoCheck { } /** @stable */ -export declare class ElementRef { - /** @stable */ nativeElement: any; - constructor(nativeElement: any); +export declare class ElementRef { + /** @stable */ nativeElement: T; + constructor(nativeElement: T); } /** @experimental */