From b44d772233b4ee6b55cbc4b1957ad12253e93744 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Sun, 12 Apr 2026 17:26:34 +0200 Subject: [PATCH 1/3] refactor: remove unnecessary blank line in getNodeSuggestions.ts --- src/suggestion/getNodeSuggestions.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/suggestion/getNodeSuggestions.ts b/src/suggestion/getNodeSuggestions.ts index 40cffd0..dfa5a64 100644 --- a/src/suggestion/getNodeSuggestions.ts +++ b/src/suggestion/getNodeSuggestions.ts @@ -35,7 +35,6 @@ export const getNodeSuggestions = ( ${functions?.map((_, i) => `const check${i}: TargetType = {} as F${i};`).join("\n")} `; - const fileName = "index.ts"; const host = createCompilerHost(fileName, sourceCode); const sourceFile = host.getSourceFile(fileName)!; From 2be668c4dfebc098180f3d596aefec3839169184 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Sun, 12 Apr 2026 17:26:42 +0200 Subject: [PATCH 2/3] test: add negative case for number addition in nodeSuggestion tests --- test/nodeSuggestion.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/nodeSuggestion.test.ts b/test/nodeSuggestion.test.ts index 6058b0e..5254654 100644 --- a/test/nodeSuggestion.test.ts +++ b/test/nodeSuggestion.test.ts @@ -44,6 +44,10 @@ describe("getNodeSuggestions", () => { 'std::control::value' ])) + expect(map).toEqual(expect.not.arrayContaining([ + "std::number::add" + ])) + }); it("should suggest functions with compatible return types and prioritize exact matches for boolean", () => { From 12ea50b592fd6450db580054079d167468ddb277 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Sun, 12 Apr 2026 17:26:49 +0200 Subject: [PATCH 3/3] feat: add ReturnType utility type to Utils namespace in utils.ts --- src/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 143cfdf..950bfe7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -46,6 +46,12 @@ export const MINIMAL_LIB = ` interface NewableFunction extends Function {} interface IArguments { } interface RegExp { } + + declare namespace Utils { + type ReturnType any> = T extends (...args: any) => infer R ? R : any; + } + + import ReturnType = Utils.ReturnType; `; /**