From 7369895450364023caf7e3a0662286fea492bc36 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Thu, 7 Oct 2021 14:42:57 +1100 Subject: [PATCH] Make the types generic for the angular decorators --- app/angular/src/client/preview/decorators.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/angular/src/client/preview/decorators.ts b/app/angular/src/client/preview/decorators.ts index a3cf2593b629..8b2b3824c5a7 100644 --- a/app/angular/src/client/preview/decorators.ts +++ b/app/angular/src/client/preview/decorators.ts @@ -6,9 +6,11 @@ import { isComponent } from './angular-beta/utils/NgComponentAnalyzer'; import { ICollection, NgModuleMetadata } from './types'; import { AngularFramework } from './types-6-0'; -export const moduleMetadata = ( +// We use `any` here as the default type rather than `Args` because we need something that is +// castable to any component-specific args type when the user is being careful. +export const moduleMetadata = ( metadata: Partial -): DecoratorFunction => (storyFn) => { +): DecoratorFunction => (storyFn) => { const story = storyFn(); const storyMetadata = story.moduleMetadata || {}; metadata = metadata || {}; @@ -28,10 +30,10 @@ export const moduleMetadata = ( }; }; -export const componentWrapperDecorator = ( +export const componentWrapperDecorator = ( element: Type | ((story: string) => string), - props?: ICollection | ((storyContext: StoryContext) => ICollection) -): DecoratorFunction => (storyFn, storyContext) => { + props?: ICollection | ((storyContext: StoryContext) => ICollection) +): DecoratorFunction => (storyFn, storyContext) => { const story = storyFn(); const currentProps = typeof props === 'function' ? (props(storyContext) as ICollection) : props;