We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I found another issue when using hono-rate-limiter. I encountered this problem when I wanted to test modifications locally.
import { DurableObject } from 'cloudflare:workers' import { assert, expect, it } from 'vitest' import { env } from 'cloudflare:test' type ClientRateLimitInfo = { totalHits: number resetTime?: Date } class MyDurableObject extends DurableObject { value() { return this.ctx.storage.get<ClientRateLimitInfo>('value') } } it('should work', async () => { const _env = env as { MY_DURABLE_OBJECT: DurableObjectNamespace<MyDurableObject> } const id = _env.MY_DURABLE_OBJECT.idFromName('1') const stub = _env.MY_DURABLE_OBJECT.get(id) const r = await stub.value() assert(r) expect<ClientRateLimitInfo>(r) })
Error
Argument of type '{ totalHits: number; resetTime?: { toString: Stub<() => string>; toDateString: Stub<() => string>; toTimeString: Stub<() => string>; toLocaleString: Stub<{ (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?: DateTimeFormatO...' is not assignable to parameter of type 'ClientRateLimitInfo'. Types of property 'resetTime' are incompatible. Type '{ toString: Stub<() => string>; toDateString: Stub<() => string>; toTimeString: Stub<() => string>; toLocaleString: Stub<{ (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?: DateTimeFormatOptions | undefined): string; }>; ...' is not assignable to type 'Date | undefined'. Type '{ toString: Stub<() => string>; toDateString: Stub<() => string>; toTimeString: Stub<() => string>; toLocaleString: Stub<{ (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?: DateTimeFormatOptions | undefined): string; }>; ...' is not assignable to type 'Date'. The types returned by 'toString(...)' are incompatible between these types. Type 'Promise<string>' is not assignable to type 'string'.ts(2345)
Modify the implementation of Stubify to correctly ignore the Date type.
type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends Rpc.Serializable // modify ? T : T extends { [key: string | number]: any } ? { [K in keyof T]: Stubify<T[K]> } : T
The text was updated successfully, but these errors were encountered:
fix: close cloudflare#3620
893d3fb
workers-devprod
No branches or pull requests
I found another issue when using hono-rate-limiter. I encountered this problem when I wanted to test modifications locally.
Error
Modify the implementation of Stubify to correctly ignore the Date type.
The text was updated successfully, but these errors were encountered: