From dda781ecceb1e1f4649588d8ab8d1c9df5d4a8de Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 11 Jun 2019 21:13:36 +0200 Subject: [PATCH] =?UTF-8?q?fix(ivy):=20incorrect=20type=20definition=20for?= =?UTF-8?q?=20=C9=B5=C9=B5defineComponent=20(#30993)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the `ɵɵdefineComponent` method has incorrect type definitions the `directives` and `pipes` metadata property. The incorrect types allow developers to pass in already instantiated `DirectiveDef` or `ComponentDef` objects. This can cause unexpected failures because the definition internally only expects `Type` objects and now incorrectly tries to read the `ngDirectiveDef` or `ngComponentDef` of existing definitions. This issue has been unveiled by enabling the strict function parameter types flag, where the directive definitions are determined from each array element in the `directives` or `pipes` property (which can throw). PR Close #30993 --- packages/core/src/render3/interfaces/definition.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/render3/interfaces/definition.ts b/packages/core/src/render3/interfaces/definition.ts index cb4af4b03f..bbebd0a748 100644 --- a/packages/core/src/render3/interfaces/definition.ts +++ b/packages/core/src/render3/interfaces/definition.ts @@ -397,7 +397,7 @@ export type DirectiveDefList = (DirectiveDef| ComponentDef)[]; export type DirectiveTypesOrFactory = (() => DirectiveTypeList) | DirectiveTypeList; export type DirectiveTypeList = - (DirectiveDef| ComponentDef| + (DirectiveType| ComponentType| Type/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[]; export type HostBindingsFunction = @@ -412,10 +412,10 @@ export type PipeDefListOrFactory = (() => PipeDefList) | PipeDefList; export type PipeDefList = PipeDef[]; -export type PipeTypesOrFactory = (() => DirectiveTypeList) | DirectiveTypeList; +export type PipeTypesOrFactory = (() => PipeTypeList) | PipeTypeList; export type PipeTypeList = - (PipeDef| Type/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[]; + (PipeType| Type/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[]; // Note: This hack is necessary so we don't erroneously get a circular dependency