refactor(client): add default type fallback api for (#6644)

This commit is contained in:
Junyi 2025-04-11 08:45:48 +08:00 committed by GitHub
parent 49a9c6365b
commit 32ae82bb31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -26,12 +26,13 @@ import { Json } from '../input';
const JT_VALUE_RE = /^\s*{{\s*([^{}]+)\s*}}\s*$/;
type ParseOptions = {
defaultTypeOnNull?: string;
stringToDate?: boolean;
};
function parseValue(value: any, options: ParseOptions = {}): string | string[] {
if (value == null) {
return 'null';
return options.defaultTypeOnNull ?? 'null';
}
const type = typeof value;
if (type === 'string') {

View File

@ -57,6 +57,9 @@ export default class extends Instruction {
placeholder: `{{t("Duration", { ns: "${NAMESPACE}" })}}`,
useTypedConstant: [['number', { min: 1 }]],
nullable: false,
parseOptions: {
defaultTypeOnNull: 'number',
},
},
default: 1,
required: true,