feat: add typed WRN declarations

This commit is contained in:
2026-07-19 18:44:27 +05:30
parent 0d3ec79ee4
commit 94ae40d8bd
81 changed files with 942 additions and 241 deletions
+7 -4
View File
@@ -21,16 +21,19 @@ function block(source, keyword) {
function propsOf(source) {
const props = [];
for (const line of block(source, "props").split(/\r?\n/)) {
const match = line.trim().match(/^([A-Za-z][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);
const match = line
.trim()
.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\s*:\s*([^=]+?))?\s*(?:=\s*(.+))?$/);
if (!match) continue;
const [, name, rawDefault] = match;
const [, name, annotation, rawDefault] = match;
const value = rawDefault?.trim();
const type =
value === "true" || value === "false"
annotation?.trim() ||
(value === "true" || value === "false"
? "boolean"
: /^-?\d+(?:\.\d+)?$/.test(value ?? "")
? "number"
: "string";
: "string");
props.push({ name, type, required: value === undefined, default: value ?? null });
}
return props;