refac: SammoAPI에서 인자, 반환 타입을 사전 지정 가능

This commit is contained in:
2022-03-25 22:48:34 +09:00
parent be308fdb4a
commit 9d868cb2f4
5 changed files with 31 additions and 18 deletions
+1
View File
@@ -0,0 +1 @@
export function APIPathGen<T>(obj: T, callback: (path: string[])=>unknown): T;
@@ -1,9 +1,7 @@
type SubValue<V extends (...args: unknown[]) => unknown> = V | { [property: string]: SubValue<V> };
export function APIPathGen<V extends () => unknown, T extends { [property: string]: SubValue<V> }>(obj: T, callback: (path: string[]) => V, path?: string[]): T {
export function APIPathGen(obj, callback, path) {
return new Proxy(obj, {
get(target, key: string) {
let nextPath: string[];
get(target, key) {
let nextPath;
if (path === undefined) {
nextPath = [key];
}