From fc89a2c2e01d3642a557c8fca4cd0068d35f8980 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 28 Sep 2018 11:52:09 -0700 Subject: [PATCH] fix(metadata): remove the default type to work around a TS bug See https://github.com/Microsoft/TypeScript/issues/26985 --- packages/authentication/src/keys.ts | 3 ++- packages/metadata/src/types.ts | 2 +- packages/repository-json-schema/src/keys.ts | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/authentication/src/keys.ts b/packages/authentication/src/keys.ts index 8c91ce52af03..6cb825dbfa9a 100644 --- a/packages/authentication/src/keys.ts +++ b/packages/authentication/src/keys.ts @@ -105,5 +105,6 @@ export namespace AuthenticationBindings { * The key used to store log-related via @loopback/metadata and reflection. */ export const AUTHENTICATION_METADATA_KEY = MetadataAccessor.create< - AuthenticationMetadata + AuthenticationMetadata, + MethodDecorator >('authentication.operationsMetadata'); diff --git a/packages/metadata/src/types.ts b/packages/metadata/src/types.ts index ce73a2353a7d..aa66d5f1235f 100644 --- a/packages/metadata/src/types.ts +++ b/packages/metadata/src/types.ts @@ -30,7 +30,7 @@ export class MetadataAccessor { * @typeparam T Type of the metadata value * @typeparam D Type of the decorator */ - static create(key: string) { + static create(key: string) { return new MetadataAccessor(key); } } diff --git a/packages/repository-json-schema/src/keys.ts b/packages/repository-json-schema/src/keys.ts index 4ff2894c402d..9975efa1749c 100644 --- a/packages/repository-json-schema/src/keys.ts +++ b/packages/repository-json-schema/src/keys.ts @@ -9,6 +9,7 @@ import {JSONSchema6 as JSONSchema} from 'json-schema'; /** * Metadata key used to set or retrieve repository JSON Schema */ -export const JSON_SCHEMA_KEY = MetadataAccessor.create( - 'loopback:json-schema', -); +export const JSON_SCHEMA_KEY = MetadataAccessor.create< + JSONSchema, + ClassDecorator +>('loopback:json-schema');