From a83bab3057742c25429ebc09466c5c9e29b01857 Mon Sep 17 00:00:00 2001 From: atanasster Date: Thu, 27 Feb 2020 07:55:14 -0500 Subject: [PATCH] fix: tagged ode typescript fixes --- blocks/core/src/StorySource/TaggedSource.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/blocks/core/src/StorySource/TaggedSource.tsx b/blocks/core/src/StorySource/TaggedSource.tsx index 7c2ec9d51..30799f611 100644 --- a/blocks/core/src/StorySource/TaggedSource.tsx +++ b/blocks/core/src/StorySource/TaggedSource.tsx @@ -50,9 +50,14 @@ export const TaggedSource: React.FC = ({ : undefined; if (tags) { tags.forEach((tag, index) => { - const colorIdx = index % (theme.styles.length - 1); - const style = theme.styles[colorIdx]; - const color: string = style.style.color || theme.plain.color || '#fff'; + let color: string; + if (theme) { + const colorIdx = index % (theme.styles.length - 1); + const style = theme.styles[colorIdx]; + color = style.style.color || theme.plain.color || '#fff'; + } else { + color = '#333'; + } tag.color = color; }); } @@ -63,7 +68,7 @@ export const TaggedSource: React.FC = ({ className={`${className}`} style={{ ...style, padding: '10px 10px 25px 10px', margin: 0 }} > - {tokens.map((line, i) => ( + {tokens.map((line: { content: string }[], i: number) => (
{(() => { let column = 0; @@ -84,7 +89,7 @@ export const TaggedSource: React.FC = ({ : null; column += token.content.length; if (param) { - const splitToken = getTokenProps({ + const splitToken: string[] = getTokenProps({ token, key, }).children.split(/(\s+)/);