Skip to content

Commit ddd7bba

Browse files
authored
Merge pull request #54 from code0-tech/feat/#51
Better testing of node suggestions. Because currently its broken and its suggest everything
2 parents 12268b0 + 12ea50b commit ddd7bba

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/suggestion/getNodeSuggestions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export const getNodeSuggestions = (
3535
${functions?.map((_, i) => `const check${i}: TargetType = {} as F${i};`).join("\n")}
3636
`;
3737

38-
3938
const fileName = "index.ts";
4039
const host = createCompilerHost(fileName, sourceCode);
4140
const sourceFile = host.getSourceFile(fileName)!;

src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ export const MINIMAL_LIB = `
4646
interface NewableFunction extends Function {}
4747
interface IArguments { }
4848
interface RegExp { }
49+
50+
declare namespace Utils {
51+
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
52+
}
53+
54+
import ReturnType = Utils.ReturnType;
4955
`;
5056

5157
/**

test/nodeSuggestion.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ describe("getNodeSuggestions", () => {
4444
'std::control::value'
4545
]))
4646

47+
expect(map).toEqual(expect.not.arrayContaining([
48+
"std::number::add"
49+
]))
50+
4751
});
4852

4953
it("should suggest functions with compatible return types and prioritize exact matches for boolean", () => {

0 commit comments

Comments
 (0)