@@ -3,21 +3,22 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
import { RemotePrerenderFunction , RemoteQueryFunction } from '@sveltejs/kit' ;
4
4
5
5
const schema : StandardSchemaV1 < string > = null as any ;
6
+ const schema2 : StandardSchemaV1 < string , number > = null as any ;
6
7
7
8
function query_tests ( ) {
8
9
const no_args : RemoteQueryFunction < void , string > = query ( ( ) => 'Hello world' ) ;
9
- no_args ( ) ;
10
+ void no_args ( ) ;
10
11
// @ts -expect-error
11
- no_args ( '' ) ;
12
+ void no_args ( '' ) ;
12
13
13
14
const one_arg : RemoteQueryFunction < number , string > = query ( 'unchecked' , ( a : number ) =>
14
15
a . toString ( )
15
16
) ;
16
- one_arg ( 1 ) ;
17
+ void one_arg ( 1 ) ;
17
18
// @ts -expect-error
18
- one_arg ( '1' ) ;
19
+ void one_arg ( '1' ) ;
19
20
// @ts -expect-error
20
- one_arg ( ) ;
21
+ void one_arg ( ) ;
21
22
22
23
async function query_without_args ( ) {
23
24
const q = query ( ( ) => 'Hello world' ) ;
@@ -27,45 +28,52 @@ function query_tests() {
27
28
const wrong : number = await q ( ) ;
28
29
wrong ;
29
30
// @ts -expect-error
30
- q ( 1 ) ;
31
+ void q ( 1 ) ;
31
32
// @ts -expect-error
32
- query ( ( a : string ) => 'hi' ) ;
33
+ query ( ( _ : string ) => 'hi' ) ;
33
34
}
34
- query_without_args ( ) ;
35
+ void query_without_args ( ) ;
35
36
36
37
async function query_unsafe ( ) {
37
38
const q = query ( 'unchecked' , ( a : number ) => a ) ;
38
39
const result : number = await q ( 1 ) ;
39
40
result ;
40
41
// @ts -expect-error
41
- q ( 1 , 2 , 3 ) ;
42
+ void q ( 1 , 2 , 3 ) ;
42
43
// @ts -expect-error
43
- q ( '1' , '2' ) ;
44
+ void q ( '1' , '2' ) ;
44
45
}
45
- query_unsafe ( ) ;
46
+ void query_unsafe ( ) ;
46
47
47
- async function query_schema ( ) {
48
+ async function query_schema_input_only ( ) {
48
49
const q = query ( schema , ( a ) => a ) ;
49
50
const result : string = await q ( '1' ) ;
50
51
result ;
51
52
}
52
- query_schema ( ) ;
53
+ void query_schema_input_only ( ) ;
54
+
55
+ async function query_schema_input_and_output ( ) {
56
+ const q = query ( schema2 , ( a ) => a ) ;
57
+ const result : number = await q ( '1' ) ;
58
+ result ;
59
+ }
60
+ void query_schema_input_and_output ( ) ;
53
61
}
54
62
query_tests ( ) ;
55
63
56
64
function prerender_tests ( ) {
57
65
const no_args : RemotePrerenderFunction < void , string > = prerender ( ( ) => 'Hello world' ) ;
58
- no_args ( ) ;
66
+ void no_args ( ) ;
59
67
// @ts -expect-error
60
- no_args ( '' ) ;
68
+ void no_args ( '' ) ;
61
69
const one_arg : RemotePrerenderFunction < number , string > = prerender ( 'unchecked' , ( a : number ) =>
62
70
a . toString ( )
63
71
) ;
64
- one_arg ( 1 ) ;
72
+ void one_arg ( 1 ) ;
65
73
// @ts -expect-error
66
- one_arg ( '1' ) ;
74
+ void one_arg ( '1' ) ;
67
75
// @ts -expect-error
68
- one_arg ( ) ;
76
+ void one_arg ( ) ;
69
77
70
78
async function prerender_without_args ( ) {
71
79
const q = prerender ( ( ) => 'Hello world' ) ;
@@ -75,31 +83,31 @@ function prerender_tests() {
75
83
const wrong : number = await q ( ) ;
76
84
wrong ;
77
85
// @ts -expect-error
78
- q ( 1 ) ;
86
+ void q ( 1 ) ;
79
87
// @ts -expect-error
80
- query ( ( a : string ) => 'hi' ) ;
88
+ query ( ( _ : string ) => 'hi' ) ;
81
89
}
82
- prerender_without_args ( ) ;
90
+ void prerender_without_args ( ) ;
83
91
84
92
async function prerender_unsafe ( ) {
85
93
const q = prerender ( 'unchecked' , ( a : number ) => a ) ;
86
94
const result : number = await q ( 1 ) ;
87
95
result ;
88
96
// @ts -expect-error
89
- q ( 1 , 2 , 3 ) ;
97
+ void q ( 1 , 2 , 3 ) ;
90
98
// @ts -expect-error
91
- q ( '1' , '2' ) ;
99
+ void q ( '1' , '2' ) ;
92
100
}
93
- prerender_unsafe ( ) ;
101
+ void prerender_unsafe ( ) ;
94
102
95
103
async function prerender_schema ( ) {
96
104
const q = prerender ( schema , ( a ) => a ) ;
97
105
const result : string = await q ( '1' ) ;
98
106
result ;
99
107
}
100
- prerender_schema ( ) ;
108
+ void prerender_schema ( ) ;
101
109
102
- async function prerender_schema_entries ( ) {
110
+ function prerender_schema_entries ( ) {
103
111
const q = prerender ( schema , ( a ) => a , { inputs : ( ) => [ '1' ] } ) ;
104
112
q ;
105
113
// @ts -expect-error
@@ -125,31 +133,31 @@ function command_tests() {
125
133
const wrong : number = await cmd ( ) ;
126
134
wrong ;
127
135
}
128
- command_without_args ( ) ;
136
+ void command_without_args ( ) ;
129
137
130
138
async function command_unsafe ( ) {
131
139
const cmd = command ( 'unchecked' , ( a : string ) => a ) ;
132
140
const result : string = await cmd ( 'test' ) ;
133
141
result ;
134
142
// @ts -expect-error
135
- cmd ( 1 ) ;
143
+ void cmd ( 1 ) ;
136
144
// @ts -expect-error
137
- cmd ( '1' , 2 ) ;
145
+ void cmd ( '1' , 2 ) ;
138
146
}
139
- command_unsafe ( ) ;
147
+ void command_unsafe ( ) ;
140
148
141
149
async function command_schema ( ) {
142
150
const cmd = command ( schema , ( a ) => a ) ;
143
151
const result : string = await cmd ( 'foo' ) ;
144
152
result ;
145
153
// @ts -expect-error
146
- cmd ( 123 ) ;
154
+ void cmd ( 123 ) ;
147
155
}
148
- command_schema ( ) ;
156
+ void command_schema ( ) ;
149
157
}
150
158
command_tests ( ) ;
151
159
152
- async function form_tests ( ) {
160
+ function form_tests ( ) {
153
161
const q = query ( ( ) => '' ) ;
154
162
const f = form ( ( f ) => {
155
163
f . get ( '' ) ;
0 commit comments