From 35291e5e7b52dc2cfb59071a7d39750edaee8527 Mon Sep 17 00:00:00 2001 From: 233mawile <903945079@qq.com> Date: Thu, 13 Jul 2023 14:11:29 +0800 Subject: [PATCH] fix(typography-warning): [typography] warning when typography is not existed --- .../juno-core/src/foundation/styles/typography.ts | 12 +++++++++++- sync-github.json | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/juno-core/src/foundation/styles/typography.ts b/packages/juno-core/src/foundation/styles/typography.ts index c123612a..b83c0f59 100644 --- a/packages/juno-core/src/foundation/styles/typography.ts +++ b/packages/juno-core/src/foundation/styles/typography.ts @@ -1,6 +1,7 @@ import { css } from '../styled-components'; import { RcThemeProps } from '../theme/theme.type'; import { RcTypographyKeys } from '../theme/typography.type'; +import { logInDev } from '../utils'; /** * get typography key value with token @@ -17,7 +18,16 @@ function typographyProp(name: RcTypographyKeys, key: string) { return ({ theme }: RcThemeProps) => { const themeOfTypography = theme.typography[name]; if (typeof themeOfTypography !== 'object') { - throw new Error(`Unexpected typography name: ${name}`); + if (process.env.NODE_ENV !== 'production') { + throw new Error(`Unexpected typography name: ${name}`); + } else { + logInDev({ + message: `Unexpected typography name: ${name}`, + component: 'typographyProp', + level: 'warn', + }); + return undefined; + } } return themeOfTypography[key]; }; diff --git a/sync-github.json b/sync-github.json index 6b88be54..715bfe25 100644 --- a/sync-github.json +++ b/sync-github.json @@ -1,3 +1,3 @@ { - "latestCommitSHA": "e8ab96f9423498e6138559bebf947058973754aa" + "latestCommitSHA": "67e2f0e9b0ddeb1fe1f09327d3b32011acfa5051" } \ No newline at end of file