Fixed broken .d.ts fields parsing logic

This commit is contained in:
bigguy345 committed 2026-02-25 16:29:52 +02:00
1 parent f1d902849e
commit 5b8827549f
2 files changed
+13 -8

No files matched your search

@@ -202,9 +202,11 @@ public final class FieldInfo {
*/
public static FieldInfo fromJSField(JSFieldInfo jsField, TypeInfo containingType) {
String name = jsField.getName();
// Resolve the type from the JS type registry
TypeInfo type = resolveJSType(jsField.getType());
TypeInfo type = jsField.getResolvedType(containingType);
if (type == null || !type.isResolved()) {
type = resolveJSType(jsField.getType());
}
// JS fields are public by default, readonly maps to final
int modifiers = Modifier.PUBLIC;
@@ -587,13 +587,16 @@ public class TypeScriptDefinitionParser {
// Parse fields (that aren't method signatures)
Matcher fieldMatcher = FIELD_PATTERN.matcher(body);
while (fieldMatcher.find()) {
String fieldText = fieldMatcher.group(0);
// Skip if this looks like a method (has parentheses in the match)
if (fieldText.contains("(")) continue;
boolean readonly = fieldMatcher.group(1) != null;
String fieldName = fieldMatcher.group(2);
// CNPC+ base event implementation CustomNPCsEvent exposes a public "API" field that
// ends up polluting autocomplete on every event via ICustomNPCsEvent inheritance.
// Keep parsing other fields, but skip this one.
if ("ICustomNPCsEvent".equals(typeInfo.getSimpleName()) && "API".equals(fieldName))
continue;
String fieldType = cleanType(fieldMatcher.group(3));
boolean readonly = fieldMatcher.group(1) != null;
JSFieldInfo field = new JSFieldInfo(fieldName, fieldType, readonly);