diff --git a/dts-patches/ecmascript/Array.d.ts b/dts-patches/ecmascript/Array.d.ts index 85d7ab4ad..45c6e345f 100644 --- a/dts-patches/ecmascript/Array.d.ts +++ b/dts-patches/ecmascript/Array.d.ts @@ -61,7 +61,7 @@ export interface Array { length: number; /** Combines two or more arrays and returns a new array without modifying the original */ - concat(...items: T): T[]; + concat(...items: T[]): T[]; /** Tests whether all elements in the array pass the provided test function */ every(callback: Java.java.util.function.Function): boolean; @@ -88,7 +88,7 @@ export interface Array { pop(): T; /** Adds one or more elements to the end of an array and returns the new length */ - push(...items: T): number; + push(...items: T[]): number; /** Applies a function against an accumulator and each element to reduce the array to a single value */ reduce(callback: Java.java.util.function.BiFunction, initialValue: any): any; @@ -112,11 +112,11 @@ export interface Array { sort(compareFn: Java.java.util.function.BiFunction): T[]; /** Changes the contents of an array by removing or replacing existing elements and/or adding new ones */ - splice(start: number, deleteCount: number, ...items: T): T[]; + splice(start: number, deleteCount: number, ...items: T[]): T[]; /** Returns a string representation of the array */ toString(): string; /** Adds one or more elements to the beginning of an array and returns the new length */ - unshift(...items: T): number; + unshift(...items: T[]): number; } diff --git a/dts-patches/ecmascript/Math.d.ts b/dts-patches/ecmascript/Math.d.ts index b4890d572..30f7e2889 100644 --- a/dts-patches/ecmascript/Math.d.ts +++ b/dts-patches/ecmascript/Math.d.ts @@ -103,10 +103,10 @@ export interface Math { static log(x: number): number; /** Returns the largest of zero or more numbers */ - static max(...values: number): number; + static max(...values: number[]): number; /** Returns the smallest of zero or more numbers */ - static min(...values: number): number; + static min(...values: number[]): number; /** Returns base raised to the power of exponent */ static pow(x: number, y: number): number; diff --git a/dts-patches/ecmascript/String.d.ts b/dts-patches/ecmascript/String.d.ts index 549f136a4..8a48033e2 100644 --- a/dts-patches/ecmascript/String.d.ts +++ b/dts-patches/ecmascript/String.d.ts @@ -62,7 +62,7 @@ export interface String { length: number; /** Creates a string from one or more Unicode character codes (e.g., String.fromCharCode(65, 66, 67) returns "ABC") */ - static fromCharCode(...codes: number): string; + static fromCharCode(...codes: number[]): string; /** Returns the Unicode code point (0–65535) of the character at the specified index. Unlike Java's charAt() + cast, this returns the numeric code directly. */ charCodeAt(pos: number): number; diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/TypeScriptDefinitionParser.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/TypeScriptDefinitionParser.java index ce9689e53..9c82e63c4 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/TypeScriptDefinitionParser.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/TypeScriptDefinitionParser.java @@ -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);