-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
53 lines (41 loc) · 2.12 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
import route from './route';
// Test route name autocompletion
route();
// Test route parameter name autocompletion
route('posts.comments.store', {});
// TODO once we can detect whether params are required/optional @ts-expect-error missing required 'post' parameter
route('posts.comments.show', { comment: 2 });
// TODO once we can detect whether params are required/optional @ts-expect-error missing required 'comment' parameter
route('posts.comments.show', { post: 2 });
route('posts.comments.show', { post: 2, comment: 9 });
// Allows random extra object properties
route('posts.comments.show', { post: 2, comment: 9, foo: 'bar' });
// Allows any property order
route('posts.comments.show', { comment: 2, post: 9 });
// Allows random extra nested object properties
route('posts.comments.show', { post: { id: 2, foo: 'bar' } });
route('posts.comments.show', { post: { id: 1, foo: 'bar' } });
// @ts-expect-error missing 'id' key in post parameter object
route('posts.comments.show', { post: { foo: 'bar' } });
route('posts.comments.show', { comment: { uuid: 1, foo: 'bar' } });
// @ts-expect-error missing 'uuid' key in comment parameter object
route('posts.comments.show', { comment: { foo: 'bar' } });
// @ts-expect-error missing 'uuid' key in comment parameter object
// 'id' doesn't fix it because 'id' is the default/fallback but this
// parameter has an explicity 'uuid' binding, so it's required
route('posts.comments.show', { comment: { id: 2 } });
route('posts.comments.show', [2, { uuid: 3 }]);
route('posts.comments.show', [{ id: 2 }, 3]);
route('posts.comments.show', [{ id: 2 }, { uuid: 3 }]);
// @ts-expect-error missing 'id' in post parameter object
route('posts.comments.show', [{ x: 2 }, { uuid: 3 }]);
// @ts-expect-error missing 'uuid' key in comment parameter object
route('posts.comments.show', [{ id: 2 }, { id: 3 }]);
route('posts.comments.show', [{ id: 2 }, { uuid: 3 }, { x: 'y' }]);
route('posts.comments.show', ['foo', 'bar']);
route('posts.comments.show', [{ id: 2 }, 'bar']);
route('posts.comments.show', [1, 'foo', 3]);
// Test router method autocompletion
route().has('x');
// Test router getter autocompletion
route().params.x