ty-fetch 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/base.d.ts +14 -14
  2. package/index.d.ts +14 -14
  3. package/package.json +1 -1
package/base.d.ts CHANGED
@@ -3,9 +3,9 @@ export class HTTPError extends Error {
3
3
  }
4
4
 
5
5
  export interface Options<
6
- TBody = never,
7
- TPathParams = never,
8
- TQueryParams = never,
6
+ TBody = unknown,
7
+ TPathParams = Record<string, string>,
8
+ TQueryParams = Record<string, string | number | boolean>,
9
9
  THeaders extends Record<string, string> = Record<string, string>,
10
10
  > extends Omit<RequestInit, 'body' | 'headers'> {
11
11
  body?: TBody;
@@ -31,19 +31,19 @@ export interface StreamResult<T = unknown> extends AsyncIterable<T> {
31
31
  }
32
32
 
33
33
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- type BaseOptions = Options<any, Record<string, any>, Record<string, any>>;
34
+ type Untyped = any;
35
35
 
36
36
  export interface TyFetch {
37
- (url: string, options?: BaseOptions): Promise<FetchResult<any>>;
38
- get(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
39
- post(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
40
- put(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
41
- patch(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
42
- delete(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
43
- head(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
44
- stream(url: string, options?: BaseOptions): StreamResult;
45
- create(defaults?: BaseOptions): TyFetch;
46
- extend(defaults?: BaseOptions): TyFetch;
37
+ <T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
38
+ get<T = Untyped>(url: string, options?: Options<never>): Promise<FetchResult<T>>;
39
+ post<T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
40
+ put<T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
41
+ patch<T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
42
+ delete<T = Untyped>(url: string, options?: Options<never>): Promise<FetchResult<T>>;
43
+ head<T = Untyped>(url: string, options?: Options<never>): Promise<FetchResult<T>>;
44
+ stream<T = Untyped>(url: string, options?: Options): StreamResult<T>;
45
+ create(defaults?: Options): TyFetch;
46
+ extend(defaults?: Options): TyFetch;
47
47
  use(middleware: Middleware): TyFetch;
48
48
  HTTPError: typeof HTTPError;
49
49
  }
package/index.d.ts CHANGED
@@ -3,9 +3,9 @@ export class HTTPError extends Error {
3
3
  }
4
4
 
5
5
  export interface Options<
6
- TBody = never,
7
- TPathParams = never,
8
- TQueryParams = never,
6
+ TBody = unknown,
7
+ TPathParams = Record<string, string>,
8
+ TQueryParams = Record<string, string | number | boolean>,
9
9
  THeaders extends Record<string, string> = Record<string, string>,
10
10
  > extends Omit<RequestInit, 'body' | 'headers'> {
11
11
  body?: TBody;
@@ -31,19 +31,19 @@ export interface StreamResult<T = unknown> extends AsyncIterable<T> {
31
31
  }
32
32
 
33
33
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- type BaseOptions = Options<any, Record<string, any>, Record<string, any>>;
34
+ type Untyped = any;
35
35
 
36
36
  export interface TyFetch {
37
- (url: string, options?: BaseOptions): Promise<FetchResult<any>>;
38
- get(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
39
- post(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
40
- put(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
41
- patch(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
42
- delete(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
43
- head(url: string, options?: BaseOptions): Promise<FetchResult<any>>;
44
- stream(url: string, options?: BaseOptions): StreamResult;
45
- create(defaults?: BaseOptions): TyFetch;
46
- extend(defaults?: BaseOptions): TyFetch;
37
+ <T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
38
+ get<T = Untyped>(url: string, options?: Options<never>): Promise<FetchResult<T>>;
39
+ post<T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
40
+ put<T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
41
+ patch<T = Untyped>(url: string, options?: Options): Promise<FetchResult<T>>;
42
+ delete<T = Untyped>(url: string, options?: Options<never>): Promise<FetchResult<T>>;
43
+ head<T = Untyped>(url: string, options?: Options<never>): Promise<FetchResult<T>>;
44
+ stream<T = Untyped>(url: string, options?: Options): StreamResult<T>;
45
+ create(defaults?: Options): TyFetch;
46
+ extend(defaults?: Options): TyFetch;
47
47
  use(middleware: Middleware): TyFetch;
48
48
  HTTPError: typeof HTTPError;
49
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ty-fetch",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Automatic TypeScript types for any REST API. No codegen, no manual types — just fetch.",
5
5
  "license": "MIT",
6
6
  "keywords": [