From af80bdb470261c97863dba37df5c310531a62f25 Mon Sep 17 00:00:00 2001 From: Ajit Singh Date: Sat, 18 Jul 2020 18:35:28 +0530 Subject: [PATCH] fix(core): `Attribute` decorator `attributeName` is mandatory (#38131) `Attribute` decorator has defined `attributeName` as optional but actually its mandatory and compiler throws an error if `attributeName` is undefined. Made `attributeName` mandatory in the `Attribute` decorator to reflect this functionality Fixes #32658 PR Close #38131 --- goldens/public-api/core/core.d.ts | 2 +- packages/compiler/src/core.ts | 4 ++-- packages/core/src/di/metadata.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/goldens/public-api/core/core.d.ts b/goldens/public-api/core/core.d.ts index 3048dddf4d..6334c6632a 100644 --- a/goldens/public-api/core/core.d.ts +++ b/goldens/public-api/core/core.d.ts @@ -53,7 +53,7 @@ export declare function asNativeElements(debugEls: DebugElement[]): any; export declare function assertPlatform(requiredToken: any): PlatformRef; export declare interface Attribute { - attributeName?: string; + attributeName: string; } export declare const Attribute: AttributeDecorator; diff --git a/packages/compiler/src/core.ts b/packages/compiler/src/core.ts index cf3175985d..f6612c93de 100644 --- a/packages/compiler/src/core.ts +++ b/packages/compiler/src/core.ts @@ -22,10 +22,10 @@ export const createInjectionToken = makeMetadataFactory( 'InjectionToken', (desc: string) => ({_desc: desc, ɵprov: undefined})); export interface Attribute { - attributeName?: string; + attributeName: string; } export const createAttribute = - makeMetadataFactory('Attribute', (attributeName?: string) => ({attributeName})); + makeMetadataFactory('Attribute', (attributeName: string) => ({attributeName})); export interface Query { descendants: boolean; diff --git a/packages/core/src/di/metadata.ts b/packages/core/src/di/metadata.ts index 2790c0152f..521d6faf7b 100644 --- a/packages/core/src/di/metadata.ts +++ b/packages/core/src/di/metadata.ts @@ -271,7 +271,7 @@ export interface Attribute { /** * The name of the attribute whose value can be injected. */ - attributeName?: string; + attributeName: string; } /**