From 8446f9ba9e9f6308ffa5fe7eaee976013a91ab40 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Fri, 16 May 2025 13:04:06 +0200 Subject: [PATCH] forgot to add new function to index.d.ts --- index.d.ts | 2 ++ lib/generics/generics.js | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index dd9b55c..d6192d9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -177,6 +177,8 @@ export function apply(input: any): any; export function assignFn(funType: any, paramType: any): any; +export function assignFnSubstitutions(funType: any, paramType: any): [any, any]; + export function capitalizeFirstLetter(val: any): any; export function compareBools(x: any): any; diff --git a/lib/generics/generics.js b/lib/generics/generics.js index 110b2d4..f5688b1 100644 --- a/lib/generics/generics.js +++ b/lib/generics/generics.js @@ -187,8 +187,8 @@ export const substitute = (type, substitutions, stack=[]) => { }; export const assignFn = (funType, paramType) => { - const [result] = assignFnSubstitutions(funType, paramType); - return result; + const [outType] = assignFnSubstitutions(funType, paramType); + return outType; }; // same as above, but also returns the substitutions that took place @@ -202,7 +202,8 @@ export const assignFnSubstitutions = (funType, paramType) => { const {substitutions} = __unify(inType, paramType); // console.log(substitutions, prettyT(outType)); const substitutedFnType = substitute(outType, substitutions); - return [recomputeTypeVars([substitutedFnType])[0], substitutions]; + const computedOutType = recomputeTypeVars([substitutedFnType])[0]; + return [computedOutType, substitutions]; } // Ensures that no type variables overlap