mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 07:39:41 +00:00
Properly parsed TypeScript standard varargs syntax
This commit is contained in:
1 parent
6547225e8d
commit
9f26b27210
4 files changed
+17
-8
No files matched your search
+10
-1
@@ -636,7 +636,16 @@ public class TypeScriptDefinitionParser {
|
||||
String name = part.substring(0, colonIndex).trim().replace("?", "");
|
||||
String type = cleanType(part.substring(colonIndex + 1).trim());
|
||||
boolean isVarArg = name.startsWith("...");
|
||||
if (isVarArg) name = name.substring(3).trim();
|
||||
if (isVarArg) {
|
||||
name = name.substring(3).trim();
|
||||
// Varargs in TS are typed as arrays (e.g. ...codes: number[])
|
||||
// Strip the array wrapper to get the element type since isVarArg already implies array
|
||||
if (type.endsWith("[]")) {
|
||||
type = type.substring(0, type.length() - 2).trim();
|
||||
} else if (type.startsWith("Array<") && type.endsWith(">")) {
|
||||
type = type.substring(6, type.length() - 1).trim();
|
||||
}
|
||||
}
|
||||
JSMethodInfo.JSParameterInfo param = new JSMethodInfo.JSParameterInfo(name, type);
|
||||
param.setVarArg(isVarArg);
|
||||
result.add(param);
|
||||
|
||||
Reference in new issue
Block a user