chore: fix type check for i18n (#30058)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-24 16:31:16 +08:00
committed by GitHub
parent 0f41924db4
commit 1e3823e605
155 changed files with 560 additions and 1015 deletions

View File

@ -44,7 +44,7 @@ const OutputVarList: FC<Props> = ({
if (!isValid) {
setToastHandler(Toast.notify({
type: 'error',
message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }),
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, { key: errorKey }),
}))
return
}

View File

@ -57,7 +57,7 @@ const VarList: FC<Props> = ({
if (!isValid) {
setToastHandle(Toast.notify({
type: 'error',
message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }),
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, { key: errorKey }),
}))
return
}

View File

@ -72,7 +72,7 @@ const OperationSelector: FC<OperationSelectorProps> = ({
className={`system-sm-regular overflow-hidden truncate text-ellipsis
${selectedItem ? 'text-components-input-text-filled' : 'text-components-input-text-disabled'}`}
>
{selectedItem?.name ? t(`${i18nPrefix}.operations.${selectedItem?.name}`) : t(`${i18nPrefix}.operations.title`)}
{selectedItem?.name ? t(`${i18nPrefix}.operations.${selectedItem?.name}` as any) as string : t(`${i18nPrefix}.operations.title` as any) as string}
</span>
</div>
<RiArrowDownSLine className={`h-4 w-4 text-text-quaternary ${disabled && 'text-components-input-text-placeholder'} ${open && 'text-text-secondary'}`} />
@ -83,7 +83,7 @@ const OperationSelector: FC<OperationSelectorProps> = ({
<div className="flex w-[140px] flex-col items-start rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg">
<div className="flex flex-col items-start self-stretch p-1">
<div className="flex items-start self-stretch px-3 pb-0.5 pt-1">
<div className="system-xs-medium-uppercase flex grow text-text-tertiary">{t(`${i18nPrefix}.operations.title`)}</div>
<div className="system-xs-medium-uppercase flex grow text-text-tertiary">{t(`${i18nPrefix}.operations.title` as any) as string}</div>
</div>
{items.map(item => (
item.value === 'divider'
@ -100,7 +100,7 @@ const OperationSelector: FC<OperationSelectorProps> = ({
}}
>
<div className="flex min-h-5 grow items-center gap-1 px-1">
<span className="system-sm-medium flex grow text-text-secondary">{t(`${i18nPrefix}.operations.${item.name}`)}</span>
<span className="system-sm-medium flex grow text-text-secondary">{t(`${i18nPrefix}.operations.${item.name}` as any) as string}</span>
</div>
{item.value === value && (
<div className="flex items-center justify-center">

View File

@ -73,7 +73,7 @@ const NodeComponent: FC<NodeProps<AssignerNodeType>> = ({
nodeType={node?.data.type}
nodeTitle={node?.data.title}
rightSlot={
writeMode && <Badge className="!ml-auto shrink-0" text={t(`${i18nPrefix}.operations.${writeMode}`)} />
writeMode && <Badge className="!ml-auto shrink-0" text={t(`${i18nPrefix}.operations.${writeMode}` as any) as string} />
}
/>
</div>

View File

@ -34,7 +34,7 @@ const ConditionValue = ({
const variableSelector = variable_selector as ValueSelector
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}`) : operator
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}` as any) as string : operator
const formatValue = useCallback((c: Condition) => {
const notHasValue = comparisonOperatorNotRequireValue(c.comparison_operator)
if (notHasValue)
@ -59,7 +59,7 @@ const ConditionValue = ({
if (isSelect) {
const name = [...FILE_TYPE_OPTIONS, ...TRANSFER_METHOD].filter(item => item.value === (Array.isArray(c.value) ? c.value[0] : c.value))[0]
return name
? t(`workflow.nodes.ifElse.optionName.${name.i18nKey}`).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
? (t(`workflow.nodes.ifElse.optionName.${name.i18nKey}` as any) as string).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
const arr: string[] = b.split('.')
if (isSystemVar(arr))
return `{{${b}}}`
@ -91,9 +91,9 @@ const ConditionValue = ({
sub_variable_condition?.conditions.map((c: Condition, index) => (
<div className="relative flex h-6 items-center space-x-1" key={c.id}>
<div className="system-xs-medium text-text-accent">{c.key}</div>
<div className="system-xs-medium text-text-primary">{isComparisonOperatorNeedTranslate(c.comparison_operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${c.comparison_operator}`) : c.comparison_operator}</div>
<div className="system-xs-medium text-text-primary">{isComparisonOperatorNeedTranslate(c.comparison_operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${c.comparison_operator}` as any) as string : c.comparison_operator}</div>
{c.comparison_operator && !isEmptyRelatedOperator(c.comparison_operator) && <div className="system-xs-regular text-text-secondary">{isSelect(c) ? selectName(c) : formatValue(c)}</div>}
{index !== sub_variable_condition.conditions.length - 1 && (<div className="absolute bottom-[-10px] right-1 z-10 text-[10px] font-medium uppercase leading-4 text-text-accent">{t(`${i18nPrefix}.${sub_variable_condition.logical_operator}`)}</div>)}
{index !== sub_variable_condition.conditions.length - 1 && (<div className="absolute bottom-[-10px] right-1 z-10 text-[10px] font-medium uppercase leading-4 text-text-accent">{t(`${i18nPrefix}.${sub_variable_condition.logical_operator}` as any) as string}</div>)}
</div>
))
}

View File

@ -168,13 +168,13 @@ const ConditionItem = ({
if (isSelect) {
if (fileAttr?.key === 'type' || condition.comparison_operator === ComparisonOperator.allOf) {
return FILE_TYPE_OPTIONS.map(item => ({
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
name: t(`${optionNameI18NPrefix}.${item.i18nKey}` as any) as string,
value: item.value,
}))
}
if (fileAttr?.key === 'transfer_method') {
return TRANSFER_METHOD.map(item => ({
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
name: t(`${optionNameI18NPrefix}.${item.i18nKey}` as any) as string,
value: item.value,
}))
}

View File

@ -39,7 +39,7 @@ const ConditionOperator = ({
const options = useMemo(() => {
return getOperators(varType, file).map((o) => {
return {
label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}`) : o,
label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}` as any) as string : o,
value: o,
}
})
@ -65,7 +65,7 @@ const ConditionOperator = ({
{
selectedOption
? selectedOption.label
: t(`${i18nPrefix}.select`)
: t(`${i18nPrefix}.select` as any) as string
}
<RiArrowDownSLine className="ml-1 h-3.5 w-3.5" />
</Button>

View File

@ -35,7 +35,7 @@ const ConditionValue = ({
const { t } = useTranslation()
const nodes = useNodes()
const variableName = labelName || (isSystemVar(variableSelector) ? variableSelector.slice(0).join('.') : variableSelector.slice(1).join('.'))
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}`) : operator
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}` as any) as string : operator
const notHasValue = comparisonOperatorNotRequireValue(operator)
const node: Node<CommonNodeType> | undefined = nodes.find(n => n.id === variableSelector[0]) as Node<CommonNodeType>
const isException = isExceptionVariable(variableName, node?.data.type)
@ -63,7 +63,7 @@ const ConditionValue = ({
if (isSelect) {
const name = [...FILE_TYPE_OPTIONS, ...TRANSFER_METHOD].filter(item => item.value === (Array.isArray(value) ? value[0] : value))[0]
return name
? t(`workflow.nodes.ifElse.optionName.${name.i18nKey}`).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
? (t(`workflow.nodes.ifElse.optionName.${name.i18nKey}` as any) as string).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
const arr: string[] = b.split('.')
if (isSystemVar(arr))
return `{{${b}}}`

View File

@ -135,7 +135,7 @@ export const useNodeIterationInteractions = () => {
_isBundled: false,
_connectedSourceHandleIds: [],
_connectedTargetHandleIds: [],
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${childNodeType}`)} ${childNodeTypeCount[childNodeType]}` : t(`workflow.blocks.${childNodeType}`),
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${childNodeType}` as any) as string} ${childNodeTypeCount[childNodeType]}` : t(`workflow.blocks.${childNodeType}` as any) as string,
iteration_id: newNodeId,
type: childNodeType,
},

View File

@ -121,7 +121,7 @@ const DatasetItem: FC<Props> = ({
payload.provider === 'external' && (
<Badge
className="shrink-0 group-hover/dataset-item:hidden"
text={t('dataset.externalTag') as string}
text={t('dataset.externalTag')}
/>
)
}

View File

@ -42,7 +42,7 @@ const ConditionOperator = ({
const options = useMemo(() => {
return getOperators(variableType).map((o) => {
return {
label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}`) : o,
label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}` as any) as string : o,
value: o,
}
})
@ -68,7 +68,7 @@ const ConditionOperator = ({
{
selectedOption
? selectedOption.label
: t(`${i18nPrefix}.select`)
: t(`${i18nPrefix}.select` as any) as string
}
<RiArrowDownSLine className="ml-1 h-3.5 w-3.5" />
</Button>

View File

@ -66,13 +66,13 @@ const FilterCondition: FC<Props> = ({
if (isSelect) {
if (condition.key === 'type' || condition.comparison_operator === ComparisonOperator.allOf) {
return FILE_TYPE_OPTIONS.map(item => ({
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
name: t(`${optionNameI18NPrefix}.${item.i18nKey}` as any) as string,
value: item.value,
}))
}
if (condition.key === 'transfer_method') {
return TRANSFER_METHOD.map(item => ({
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
name: t(`${optionNameI18NPrefix}.${item.i18nKey}` as any) as string,
value: item.value,
}))
}

View File

@ -121,7 +121,7 @@ const ConfigPromptItem: FC<Props> = ({
<Tooltip
popupContent={
<div className="max-w-[180px]">{t(`${i18nPrefix}.roleDescription.${payload.role}`)}</div>
<div className="max-w-[180px]">{t(`${i18nPrefix}.roleDescription.${payload.role}` as any) as string}</div>
}
triggerClassName="w-4 h-4"
/>

View File

@ -34,7 +34,7 @@ const ConditionValue = ({
const variableSelector = variable_selector as ValueSelector
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}`) : operator
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}` as any) as string : operator
const formatValue = useCallback((c: Condition) => {
const notHasValue = comparisonOperatorNotRequireValue(c.comparison_operator)
if (notHasValue)
@ -59,7 +59,7 @@ const ConditionValue = ({
if (isSelect) {
const name = [...FILE_TYPE_OPTIONS, ...TRANSFER_METHOD].filter(item => item.value === (Array.isArray(c.value) ? c.value[0] : c.value))[0]
return name
? t(`workflow.nodes.ifElse.optionName.${name.i18nKey}`).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
? (t(`workflow.nodes.ifElse.optionName.${name.i18nKey}` as any) as string).replace(/\{\{#([^#]*)#\}\}/g, (a: string, b: string) => {
const arr: string[] = b.split('.')
if (isSystemVar(arr))
return `{{${b}}}`
@ -91,9 +91,9 @@ const ConditionValue = ({
sub_variable_condition?.conditions.map((c: Condition, index) => (
<div className="relative flex h-6 items-center space-x-1" key={c.id}>
<div className="system-xs-medium text-text-accent">{c.key}</div>
<div className="system-xs-medium text-text-primary">{isComparisonOperatorNeedTranslate(c.comparison_operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${c.comparison_operator}`) : c.comparison_operator}</div>
<div className="system-xs-medium text-text-primary">{isComparisonOperatorNeedTranslate(c.comparison_operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${c.comparison_operator}` as any) as string : c.comparison_operator}</div>
{c.comparison_operator && !isEmptyRelatedOperator(c.comparison_operator) && <div className="system-xs-regular text-text-secondary">{isSelect(c) ? selectName(c) : formatValue(c)}</div>}
{index !== sub_variable_condition.conditions.length - 1 && (<div className="absolute bottom-[-10px] right-1 z-10 text-[10px] font-medium uppercase leading-4 text-text-accent">{t(`${i18nPrefix}.${sub_variable_condition.logical_operator}`)}</div>)}
{index !== sub_variable_condition.conditions.length - 1 && (<div className="absolute bottom-[-10px] right-1 z-10 text-[10px] font-medium uppercase leading-4 text-text-accent">{t(`${i18nPrefix}.${sub_variable_condition.logical_operator}` as any) as string}</div>)}
</div>
))
}

View File

@ -145,13 +145,13 @@ const ConditionItem = ({
if (isSelect) {
if (fileAttr?.key === 'type' || condition.comparison_operator === ComparisonOperator.allOf) {
return FILE_TYPE_OPTIONS.map(item => ({
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
name: t(`${optionNameI18NPrefix}.${item.i18nKey}` as any) as string,
value: item.value,
}))
}
if (fileAttr?.key === 'transfer_method') {
return TRANSFER_METHOD.map(item => ({
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
name: t(`${optionNameI18NPrefix}.${item.i18nKey}` as any) as string,
value: item.value,
}))
}

View File

@ -39,7 +39,7 @@ const ConditionOperator = ({
const options = useMemo(() => {
return getOperators(varType, file).map((o) => {
return {
label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}`) : o,
label: isComparisonOperatorNeedTranslate(o) ? t(`${i18nPrefix}.comparisonOperator.${o}` as any) as string : o,
value: o,
}
})
@ -65,7 +65,7 @@ const ConditionOperator = ({
{
selectedOption
? selectedOption.label
: t(`${i18nPrefix}.select`)
: t(`${i18nPrefix}.select` as any) as string
}
<RiArrowDownSLine className="ml-1 h-3.5 w-3.5" />
</Button>

View File

@ -27,7 +27,7 @@ const ConditionValue = ({
value,
}: ConditionValueProps) => {
const { t } = useTranslation()
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}`) : operator
const operatorName = isComparisonOperatorNeedTranslate(operator) ? t(`workflow.nodes.ifElse.comparisonOperator.${operator}` as any) as string : operator
const notHasValue = comparisonOperatorNotRequireValue(operator)
const formatValue = useMemo(() => {
if (notHasValue)
@ -50,7 +50,7 @@ const ConditionValue = ({
if (isSelect) {
const name = [...FILE_TYPE_OPTIONS, ...TRANSFER_METHOD].filter(item => item.value === (Array.isArray(value) ? value[0] : value))[0]
return name
? t(`workflow.nodes.ifElse.optionName.${name.i18nKey}`).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
? (t(`workflow.nodes.ifElse.optionName.${name.i18nKey}` as any) as string).replace(/\{\{#([^#]*)#\}\}/g, (a, b) => {
const arr: string[] = b.split('.')
if (isSystemVar(arr))
return `{{${b}}}`

View File

@ -30,7 +30,7 @@ const Item = ({
if (!isValid) {
Toast.notify({
type: 'error',
message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: t('workflow.env.modal.name') }),
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, { key: t('workflow.env.modal.name') }) as string,
})
return false
}

View File

@ -56,7 +56,7 @@ const AddExtractParameter: FC<Props> = ({
if (!isValid) {
Toast.notify({
type: 'error',
message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }),
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, { key: errorKey }) as string,
})
return
}

View File

@ -45,7 +45,7 @@ const VarList: FC<Props> = ({
if (errorMsgKey) {
Toast.notify({
type: 'error',
message: t(errorMsgKey, { key: t(typeName) }),
message: t(errorMsgKey as any, { key: t(typeName as any) as string }) as string,
})
return false
}

View File

@ -99,7 +99,7 @@ const useConfig = (id: string, payload: StartNodeType) => {
if (errorMsgKey) {
Toast.notify({
type: 'error',
message: t(errorMsgKey, { key: t(typeName) }),
message: t(errorMsgKey as any, { key: t(typeName as any) as string }) as string,
})
return false
}

View File

@ -15,12 +15,12 @@ const ModeSwitcher = ({ mode, onChange }: ModeSwitcherProps) => {
const options = [
{
Icon: RiCalendarLine,
text: t('workflow.nodes.triggerSchedule.mode.visual'),
text: t('workflow.nodes.triggerSchedule.modeVisual'),
value: 'visual' as const,
},
{
Icon: RiCodeLine,
text: t('workflow.nodes.triggerSchedule.mode.cron'),
text: t('workflow.nodes.triggerSchedule.modeCron'),
value: 'cron' as const,
},
]

View File

@ -103,9 +103,9 @@ const useConfig = (id: string, payload: WebhookTriggerNodeType) => {
if (!isValid) {
Toast.notify({
type: 'error',
message: t(`appDebug.varKeyError.${errorMessageKey}`, {
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, {
key: t('appDebug.variableConfig.varName'),
}),
}) as string,
})
return false
}

View File

@ -120,7 +120,7 @@ const NodeVariableItem = ({
{VariableIcon}
{VariableName}
</div>
{writeMode && <Badge className="shrink-0" text={t(`${i18nPrefix}.operations.${writeMode}`)} />}
{writeMode && <Badge className="shrink-0" text={t(`${i18nPrefix}.operations.${writeMode}` as any) as string} />}
</div>
)
}

View File

@ -96,7 +96,7 @@ const VarGroupItem: FC<Props> = ({
if (!isValid) {
Toast.notify({
type: 'error',
message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }),
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, { key: errorKey }) as string,
})
return
}