-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.ts
94 lines (87 loc) · 2.39 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { Tokenize } from "./tokenizer";
import { Parser } from "./parser";
import { Interpret } from "./interpreter";
import { PathAutocomplete } from "./autocomplete";
const obj2 = {
comments: [
{
id: 1,
uid: "ah",
content: "Content 1",
},
{
id: 2,
uid: "ah",
content: "Content 2",
},
{
id: 3,
uid: "jd",
content: "Content 3",
},
{
id: 4,
uid: "jd",
content: "Content 4",
},
],
} as const;
type Toks = Tokenize<"comments[].$where(uid:ah)">;
type AST = Parser<Toks>;
type Demo = Interpret<typeof obj2, AST>;
type PathDemo = PathAutocomplete<typeof obj2>;
function get<Obj, T>(
obj: Obj,
path: T | PathAutocomplete<Obj>
): Interpret<Obj, Parser<Tokenize<T & string>>> {
return {} as Interpret<Obj, Parser<Tokenize<T & string>>>;
}
type Test1 = Tokenize<"commentsssssssssssssssss.invoices.data.users.nice.work.here.fa">;
type Test2 = Tokenize<"comments.invoices.anurag.hazra.abcdefghijklm.a">;
type ASTLimit = Parser<Test1>;
const t = get(
{
commentsssssssssssssssss: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: {
nest: {
child: [1, 2, 3],
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
} as const,
"commentsssssssssssssssss.nest.child.nest.child.nest.child.nest.child.nest.child.nest.child.nest.child.nest.child.nest.child.nest.child[]"
);