adding field parse case for when there is no default field value

This commit is contained in:
metacryst
2024-03-15 16:21:51 -05:00
parent 0675c391db
commit 7f12cf439b

View File

@@ -32,12 +32,11 @@ window.Registry = class Registry {
braceDepth -= (trimmedLine.match(/}/g) || []).length; braceDepth -= (trimmedLine.match(/}/g) || []).length;
// Check if the line is outside any function/method (top-level within the class) // Check if the line is outside any function/method (top-level within the class)
if (braceDepth === 1 && trimmedLine.includes('=') && !trimmedLine.startsWith('...')) { if (braceDepth === 1) {
// Extract the field name, which is before the '=' symbol // Attempt to match a class field declaration with or without initialization
const fieldName = trimmedLine.split('=')[0].trim(); const fieldMatch = trimmedLine.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*(=|;|\n|$)/);
// Make sure the field name doesn't include invalid characters or spaces if (fieldMatch) {
if (!fieldName.includes(' ') && !fieldName.startsWith('this.')) { fields.push(fieldMatch[1]);
fields.push(fieldName);
} }
} }