This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Updated types for 2022-04-27 #226
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@cloudflare/workers-types": minor | ||
--- | ||
|
||
Updated auto-generated types @ 2022-04-27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,7 @@ declare type BodyInitializer = BodyInit; | |
declare class ByteLengthQueuingStrategy { | ||
constructor(init: QueuingStrategyInit); | ||
readonly highWaterMark: number; | ||
size(arg1?: any): number | undefined; | ||
size(chunk?: any): number; | ||
} | ||
|
||
declare abstract class Cache { | ||
|
@@ -194,7 +194,7 @@ interface Comment { | |
} | ||
|
||
declare class CompressionStream extends TransformStream { | ||
constructor(format: string); | ||
constructor(format: "gzip" | "deflate"); | ||
} | ||
|
||
interface Console { | ||
|
@@ -214,7 +214,7 @@ interface ContentOptions { | |
declare class CountQueuingStrategy { | ||
constructor(init: QueuingStrategyInit); | ||
readonly highWaterMark: number; | ||
size(arg1?: any): number | undefined; | ||
size(chunk?: any): number; | ||
} | ||
|
||
declare abstract class Crypto { | ||
|
@@ -323,7 +323,7 @@ declare class DOMException extends Error { | |
} | ||
|
||
declare class DecompressionStream extends TransformStream { | ||
constructor(format: string); | ||
constructor(format: "gzip" | "deflate"); | ||
} | ||
|
||
declare class DigestStream extends WritableStream { | ||
|
@@ -345,6 +345,10 @@ interface DurableObject { | |
fetch(request: Request): Promise<Response>; | ||
} | ||
|
||
interface DurableObjectGetAlarmOptions { | ||
allowConcurrency?: boolean; | ||
} | ||
|
||
interface DurableObjectGetOptions { | ||
allowConcurrency?: boolean; | ||
noCache?: boolean; | ||
|
@@ -385,6 +389,11 @@ interface DurableObjectPutOptions { | |
noCache?: boolean; | ||
} | ||
|
||
interface DurableObjectSetAlarmOptions { | ||
allowConcurrency?: boolean; | ||
allowUnconfirmed?: boolean; | ||
} | ||
|
||
interface DurableObjectState { | ||
waitUntil(promise: Promise<any>): void; | ||
readonly id: DurableObjectId | string; | ||
|
@@ -419,17 +428,12 @@ interface DurableObjectStorage { | |
transaction<T>( | ||
closure: (txn: DurableObjectTransaction) => Promise<T> | ||
): Promise<T>; | ||
getAlarm( | ||
options?: DurableObjectStorageOperationsGetAlarmOptions | ||
): Promise<Date | null>; | ||
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>; | ||
setAlarm( | ||
arg2: Date, | ||
options?: DurableObjectStorageOperationsSetAlarmOptions | ||
scheduledTime: Date, | ||
options?: DurableObjectSetAlarmOptions | ||
): Promise<void>; | ||
} | ||
|
||
interface DurableObjectStorageOperationsGetAlarmOptions { | ||
allowConcurrency?: boolean; | ||
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>; | ||
} | ||
|
||
/** | ||
|
@@ -451,11 +455,6 @@ declare type DurableObjectStorageOperationsListOptions = | |
*/ | ||
declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions; | ||
|
||
interface DurableObjectStorageOperationsSetAlarmOptions { | ||
allowConcurrency?: boolean; | ||
allowUnconfirmed?: boolean; | ||
} | ||
|
||
interface DurableObjectStub extends Fetcher { | ||
readonly id: DurableObjectId; | ||
readonly name?: string; | ||
|
@@ -482,13 +481,12 @@ interface DurableObjectTransaction { | |
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>; | ||
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>; | ||
rollback(): void; | ||
getAlarm( | ||
options?: DurableObjectStorageOperationsGetAlarmOptions | ||
): Promise<Date | null>; | ||
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>; | ||
setAlarm( | ||
arg2: Date, | ||
options?: DurableObjectStorageOperationsSetAlarmOptions | ||
scheduledTime: Date, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, should this be |
||
options?: DurableObjectSetAlarmOptions | ||
): Promise<void>; | ||
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>; | ||
} | ||
|
||
interface Element { | ||
|
@@ -1003,7 +1001,13 @@ interface R2Bucket { | |
get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>; | ||
put( | ||
key: string, | ||
value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null, | ||
value: | ||
| ReadableStream | ||
| ArrayBuffer | ||
| ArrayBufferView | ||
| string | ||
| null | ||
| Blob, | ||
options?: R2PutOptions | ||
): Promise<R2Object>; | ||
delete(key: string): Promise<void>; | ||
|
@@ -1077,7 +1081,7 @@ interface R2ListOptions { | |
* } | ||
* ``` | ||
*/ | ||
include: ("httpMetadata" | "customMetadata")[]; | ||
include?: ("httpMetadata" | "customMetadata")[]; | ||
} | ||
|
||
/** | ||
|
@@ -1135,12 +1139,15 @@ declare abstract class ReadableByteStreamController { | |
readonly byobRequest: ReadableStreamBYOBRequest | null; | ||
readonly desiredSize: number | null; | ||
close(): void; | ||
enqueue(chunk: ArrayBufferView): void; | ||
enqueue(chunk: ArrayBuffer | ArrayBufferView): void; | ||
error(reason: any): void; | ||
} | ||
|
||
declare class ReadableStream { | ||
constructor(underlyingSource?: Object, queuingStrategy?: Object); | ||
constructor( | ||
underlyingSource?: UnderlyingSource, | ||
queuingStrategy?: StreamQueuingStrategy | ||
); | ||
readonly locked: boolean; | ||
cancel(reason?: any): Promise<void>; | ||
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader; | ||
|
@@ -1174,7 +1181,7 @@ declare class ReadableStreamBYOBReader { | |
declare abstract class ReadableStreamBYOBRequest { | ||
readonly view: Uint8Array | null; | ||
respond(bytesWritten: number): void; | ||
respondWithNewView(view: ArrayBufferView): void; | ||
respondWithNewView(view: ArrayBuffer | ArrayBufferView): void; | ||
readonly atLeast: number | null; | ||
} | ||
|
||
|
@@ -1814,6 +1821,26 @@ declare type URLSearchParamsInit = | |
*/ | ||
declare type URLSearchParamsInitializer = URLSearchParamsInit; | ||
|
||
interface UnderlyingSink { | ||
type?: string; | ||
start?(controller: WritableStreamDefaultController): any; | ||
write?(chunk: any, controller: WritableStreamDefaultController): any; | ||
abort?(reason: any): any; | ||
close?(): any; | ||
} | ||
|
||
interface UnderlyingSource { | ||
type?: string; | ||
autoAllocateChunkSize?: number; | ||
start?( | ||
controller: ReadableStreamDefaultController | ReadableByteStreamController | ||
): any; | ||
pull?( | ||
controller: ReadableStreamDefaultController | ReadableByteStreamController | ||
): any; | ||
cancel?(reason?: any): any; | ||
} | ||
|
||
declare class WebSocket extends EventTarget<WebSocketEventMap> { | ||
constructor(url: string, protocols?: string[] | string); | ||
accept(): void; | ||
|
@@ -1848,7 +1875,10 @@ declare type WorkerGlobalScopeEventMap = { | |
}; | ||
|
||
declare class WritableStream { | ||
constructor(underlyingSink?: Object, queuingStrategy?: Object); | ||
constructor( | ||
underlyingSink?: UnderlyingSink, | ||
queuingStrategy?: StreamQueuingStrategy | ||
); | ||
readonly locked: boolean; | ||
abort(reason: any): Promise<void>; | ||
close(): Promise<void>; | ||
|
@@ -1947,6 +1977,7 @@ type Params<P extends string = any> = Record<P, string | string[]>; | |
|
||
type EventContext<Env, P extends string, Data> = { | ||
request: Request; | ||
functionPath: string; | ||
waitUntil: (promise: Promise<any>) => void; | ||
next: (input?: Request | string, init?: RequestInit) => Promise<Response>; | ||
env: Env & { ASSETS: { fetch: typeof fetch } }; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right?
getAlarm
returns anumber
, butsetAlarm
takes aDate
? ShouldsetAlarm
takenumber | Date
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAlarm
does takenumber | Date
, I guess we need to update the type generation script to understand thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about that Matt? The type generation script is pretty stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we don't return a Date from
getAlarm
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible CFJS automatically casts numbers to
kj::Date
s?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Brendan's observation is valid. This API is asymmetric which is odd.
@xortive could you see what's causing this and see if we can fix it? thank you