Skip to content

Commit

Permalink
fix: incorrect function overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkChampagne17 committed Jul 30, 2022
1 parent 0b16d65 commit 681222f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/separated-path-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function separatedPathOf<T>(

const proxy = new Proxy({}, handler);
const callback = (
typeof arg1 === "function" ? arg1 : arg2
typeof arg2 === "function" ? arg2 : arg1
) as CallBackForPropertyAccess<T>;

callback(proxy as T);
Expand Down
8 changes: 8 additions & 0 deletions test/name-of.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ describe("nameOf", () => {
expect(age).toBe("age");
expect(length).toBe("length");
});

test("Get the property name of the function", () => {
const name = nameOf(
(foo) => foo.bar,
(fn) => fn.call
);
expect(name).toBe("call");
});
});
8 changes: 8 additions & 0 deletions test/path-of.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ describe("pathOf", () => {
const path = pathOf<typeof student>((s) => s.name[0]);
expect(path).toBe("['name']['0']");
});

test("Get the path of the function", () => {
const path = pathOf(
(foo) => foo.bar,
(fn) => fn.call
);
expect(path).toBe("['call']");
});
});
8 changes: 8 additions & 0 deletions test/separated-path-of.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ describe("separatedPathOf", () => {
expect(separatedPathIncludesAge).toEqual(["age"]);
expect(separatedPathIncludesNameAndZero).toEqual(["name", "0"]);
});

test("Get the separated path of the function", () => {
const separatedPathIncludesCall = separatedPathOf(
(foo) => foo.bar,
(fn) => fn.call
);
expect(separatedPathIncludesCall).toStrictEqual(["call"]);
});
});

0 comments on commit 681222f

Please sign in to comment.