Skip to content

Commit

Permalink
fix(kv): define null return type from KV.Namespace[get]
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed May 1, 2021
1 parent 7c9ab8b commit 58beaec
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/kv.d.ts
Expand Up @@ -13,20 +13,21 @@ export namespace KV {
}

interface Namespace {
get<T>(key: string, type: 'json'): Promise<T>;
get<T>(key: string, options: GetOptions<'json'>): Promise<T>;
get<T>(key: string, type: 'json'): Promise<T|null>;
get<T>(key: string, options: GetOptions<'json'>): Promise<T|null>;

get<T>(key: string, type: 'stream'): Promise<ReadableStream>;
get<T>(key: string, options: GetOptions<'stream'>): Promise<ReadableStream>;
get<T>(key: string, type: 'stream'): Promise<ReadableStream|null>;
get<T>(key: string, options: GetOptions<'stream'>): Promise<ReadableStream|null>;

get<T>(key: string, type: 'arrayBuffer'): Promise<ArrayBuffer>;
get<T>(key: string, options: GetOptions<'arrayBuffer'>): Promise<ArrayBuffer>;
get<T>(key: string, type: 'arrayBuffer'): Promise<ArrayBuffer|null>;
get<T>(key: string, options: GetOptions<'arrayBuffer'>): Promise<ArrayBuffer|null>;

get<T>(key: string, type: 'text'): Promise<string>;
get<T>(key: string, options: GetOptions<'text'>): Promise<string>;
get<T>(key: string, type: 'text'): Promise<string|null>;
get<T>(key: string, options: GetOptions<'text'>): Promise<string|null>;

get<T>(key: string, type?: GetFormat): Promise<string|null>; // "text"
get<T>(key: string, options?: GetOptions<GetFormat> ): Promise<string|null>; // "text"

get<T>(key: string, type?: GetFormat): Promise<string>; // "text"
get<T>(key: string, options?: GetOptions<GetFormat> ): Promise<string>; // "text"



Expand Down

0 comments on commit 58beaec

Please sign in to comment.