Parameterized Array.d.ts so it shows proper types and not just any/any[]

This commit is contained in:
bigguy345 committed 2026-03-07 00:20:23 +02:00
1 parent f78d326102
commit 6547225e8d
2 files changed
+26 -19

No files matched your search

@@ -49,6 +49,13 @@ public final class GenericContext {
* @return a context with applied bindings and bound fallbacks, or EMPTY singleton if receiverType is not generic
*/
public static GenericContext forReceiver(TypeInfo receiverType) {
// Special edge case: Array.d.ts JS type, bind T to element type so Array<T> methods resolve correctly
if (receiverType != null && receiverType.isArray() && receiverType.getElementType() != null) {
Map<String, TypeInfo> applied = new HashMap<>();
applied.put("T", receiverType.getElementType());
return new GenericContext(applied, new HashMap<>());
}
// Fast path: return singleton for non-generic types
if (receiverType == null || !hasGenerics(receiverType)) {
return EMPTY;