From 2ebe840ac5c5a11f3df98b64a6bf269c1cd23fd9 Mon Sep 17 00:00:00 2001 From: Mateusz Kadlubowski Date: Tue, 27 Aug 2024 15:21:04 +0800 Subject: [PATCH] cleanup & notes --- .../post-transform/shared/description.ts | 5 +++-- src/compiler/pre-transform/index.ts | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/compiler/post-transform/shared/description.ts b/src/compiler/post-transform/shared/description.ts index c82487f..8de94a6 100644 --- a/src/compiler/post-transform/shared/description.ts +++ b/src/compiler/post-transform/shared/description.ts @@ -90,8 +90,7 @@ export const getParametersPropertyValue = ( Property: ${JSON.stringify(property, null, 2)} `); - - // TODO: this is unsafe. If this happens, we'll just have an error later on. we want to skip instead. + // NOTE: We're emitting a warning when it happens return undefined as never; } @@ -132,6 +131,7 @@ export const getDocsPropertyValue = (options: Omit) Property: ${JSON.stringify(property, null, 2)} `); + // NOTE: We're emitting a warning when it happens return undefined as never; } @@ -167,6 +167,7 @@ export const getDescriptionPropertyValue = (options: Omit { state.defineMetaFromExportConstMeta = transformed; } - const { init } = declaration.declarations[0]; - - if (init?.type !== 'ObjectExpression') { - // TODO: Document it? - throw new Error('Invalid syntax in legacy story...'); - } + // NOTE: + // Type assertion because we already ran transform codemod function by this point (`transformed`). + // So the possible issue is on our side, not user. + const { init } = declaration.declarations[0] as ObjectExpression; const { properties } = init;