Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| note:sun_jun_22_2025 [2025/06/22 02:37] – lingao | note:sun_jun_22_2025 [2025/06/22 14:52] (current) – lingao | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| * :!: https:// | * :!: https:// | ||
| * https:// | * https:// | ||
| + | * :!: https:// | ||
| ===== How to write a code formatter ===== | ===== How to write a code formatter ===== | ||
| Line 9: | Line 10: | ||
| prettier is based on [[https:// | prettier is based on [[https:// | ||
| + | |||
| + | ===== code gen ===== | ||
| + | |||
| + | <code ts> | ||
| + | type LowcodeInterface = { | ||
| + | identifier: string; | ||
| + | fields: { name: string, type: string, comment?: string }[]; | ||
| + | comment?: string; | ||
| + | } | ||
| + | |||
| + | function printField(field: | ||
| + | return (field.comment ? ' | ||
| + | + " | ||
| + | } | ||
| + | |||
| + | function printInterface(lowcodeInterface: | ||
| + | return (lowcodeInterface.comment ? '/* ' + lowcodeInterface.comment + " */\n" : "" | ||
| + | + " | ||
| + | + lowcodeInterface.fields.map(printField).join(' | ||
| + | + " | ||
| + | } | ||
| + | |||
| + | export { printInterface }; | ||
| + | </ | ||
| + | |||