@@ -8,6 +8,9 @@ import { describe, expect, it } from "vitest";
88
99import worker from "." ;
1010
11+ type IsNever < T > = [ T ] extends [ never ] ? true : false ;
12+ type AssertNot < T extends false > = T ;
13+
1114function getStub ( environment : typeof env ) {
1215 const id = environment . SCHEDULER . idFromName ( "example" ) ;
1316 return environment . SCHEDULER . get ( id ) ;
@@ -46,6 +49,9 @@ describe("Hello World worker", () => {
4649 time
4750 } ) ;
4851
52+ // this will get a type error if scheduleTask returns `never`
53+ type _ = AssertNot < IsNever < typeof task > > ;
54+
4955 expect ( task ) . toMatchInlineSnapshot ( `
5056 {
5157 "callback": {
@@ -123,9 +129,8 @@ describe("Hello World worker", () => {
123129 "test": "test",
124130 },
125131 "time": ${
126- // @ts -expect-error I'm bad at typescript
127132 // eslint-disable-next-line @typescript-eslint/no-unsafe-call
128- taskTime . toISOString ( )
133+ await taskTime . toISOString ( )
129134 } ,
130135 "type": "delayed",
131136 }
@@ -242,11 +247,7 @@ describe("Hello World worker", () => {
242247 "payload": {
243248 "test": "test",
244249 },
245- "time": ${
246- // @ts -expect-error I'm bad at typescript
247- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
248- time . toISOString ( )
249- } ,
250+ "time": ${ await time . toISOString ( ) } ,
250251 "type": "no-schedule",
251252 }
252253 ` ) ;
@@ -268,11 +269,7 @@ describe("Hello World worker", () => {
268269 "description": "test",
269270 "id": "no-schedule-task-001",
270271 "payload": "{"test":"test"}",
271- "time": ${ Math . floor (
272- // @ts -expect-error I'm bad at typescript
273- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
274- time . getTime ( ) / 1000
275- ) } ,
272+ "time": ${ Math . floor ( ( await time . getTime ( ) ) / 1000 ) } ,
276273 "type": "no-schedule",
277274 }
278275 ` ) ;
0 commit comments