@rest-hooks/endpoint
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -6,2 +6,10 @@ # Change Log | ||
## <small>0.4.3 (2020-07-22)</small> | ||
* fix: Ambient files now typechecked, fixed some types there (#372) ([223d4a4](https://github.com/coinbase/rest-hooks/commit/223d4a4)), closes [#372](https://github.com/coinbase/rest-hooks/issues/372) | ||
## <small>0.4.2 (2020-07-22)</small> | ||
@@ -8,0 +16,0 @@ |
/* eslint-disable @typescript-eslint/ban-types */ | ||
import type { Schema } from '@rest-hooks/normalizr'; | ||
import type { Schema, schema } from '@rest-hooks/normalizr'; | ||
@@ -9,3 +9,3 @@ import type { EndpointInterface } from './interface'; | ||
export interface EndpointOptions< | ||
K extends (params: any) => string, | ||
K extends (...args: any) => string, | ||
S extends Schema | undefined = Schema | undefined, | ||
@@ -20,3 +20,3 @@ M extends true | undefined = undefined | ||
export interface EndpointExtendOptions< | ||
K extends (params: any) => string, | ||
K extends (...args: any) => string, | ||
S extends Schema | undefined = Schema | undefined, | ||
@@ -44,3 +44,8 @@ M extends true | undefined = undefined | ||
M extends true | undefined = undefined | ||
> extends EndpointInterface<F, S, M> { | ||
> | ||
extends EndpointInterface< | ||
F, | ||
S extends undefined ? schema.SchemaClass<ResolveType<F>> : S, | ||
M | ||
> { | ||
constructor: EndpointConstructor; | ||
@@ -84,4 +89,4 @@ | ||
readonly schema: S extends undefined ? ResolveType<F> : S; | ||
private _schema: S; // TODO: remove once we don't care about FetchShape compatibility | ||
readonly schema: S extends undefined ? schema.SchemaClass<ResolveType<F>> : S; | ||
readonly _schema: S; // TODO: remove once we don't care about FetchShape compatibility | ||
@@ -104,3 +109,5 @@ fetch: F; | ||
): EndpointInstance< | ||
'fetch' extends keyof typeof options ? typeof options['fetch'] : E['fetch'], | ||
'fetch' extends keyof typeof options | ||
? Exclude<typeof options['fetch'], undefined> | ||
: E['fetch'], | ||
'schema' extends keyof typeof options | ||
@@ -107,0 +114,0 @@ ? typeof options['schema'] |
@@ -7,3 +7,3 @@ import { Schema, AbstractInstanceType } from '@rest-hooks/normalizr'; | ||
(...args: Parameters<F>): InferReturn<F, S>; | ||
key(parmas?: Readonly<Parameters<F>[0]>): string; | ||
key(...args: Parameters<F>): string; | ||
readonly sideEffect?: M; | ||
@@ -10,0 +10,0 @@ readonly schema?: S; |
{ | ||
"name": "@rest-hooks/endpoint", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Declarative Network Interface Definitions", | ||
@@ -18,3 +18,3 @@ "sideEffects": false, | ||
"scripts": { | ||
"build:lib": "cp src/endpoint.d.ts lib/endpoint.d.ts && cross-env NODE_ENV=production ROOT_PATH_PREFIX='@rest-hooks/core' babel --root-mode upward src --out-dir lib --source-maps inline --extensions '.ts,.tsx,.js' --ignore '**/__tests__/**' --ignore '**/*.d.ts'", | ||
"build:lib": "cross-env NODE_ENV=production ROOT_PATH_PREFIX='@rest-hooks/core' babel --root-mode upward src --out-dir lib --source-maps inline --extensions '.ts,.tsx,.js' --ignore '**/__tests__/**' --ignore '**/*.d.ts'", | ||
"build:bundle": "rollup -c", | ||
@@ -56,5 +56,5 @@ "build:clean": "rimraf lib dist *.tsbuildinfo", | ||
"@babel/runtime": "^7.7.2", | ||
"@rest-hooks/normalizr": "^6.0.0-i.0" | ||
"@rest-hooks/normalizr": "^6.0.0-i.1" | ||
}, | ||
"gitHead": "0bb299101b7fea7dbadbbd3dab366098a028e240" | ||
"gitHead": "796bad7931b65611c4c4c1532e851e67ea6ad97b" | ||
} |
/* eslint-disable @typescript-eslint/ban-types */ | ||
import type { Schema } from '@rest-hooks/normalizr'; | ||
import type { Schema, schema } from '@rest-hooks/normalizr'; | ||
@@ -9,3 +9,3 @@ import type { EndpointInterface } from './interface'; | ||
export interface EndpointOptions< | ||
K extends (params: any) => string, | ||
K extends (...args: any) => string, | ||
S extends Schema | undefined = Schema | undefined, | ||
@@ -20,3 +20,3 @@ M extends true | undefined = undefined | ||
export interface EndpointExtendOptions< | ||
K extends (params: any) => string, | ||
K extends (...args: any) => string, | ||
S extends Schema | undefined = Schema | undefined, | ||
@@ -44,3 +44,8 @@ M extends true | undefined = undefined | ||
M extends true | undefined = undefined | ||
> extends EndpointInterface<F, S, M> { | ||
> | ||
extends EndpointInterface< | ||
F, | ||
S extends undefined ? schema.SchemaClass<ResolveType<F>> : S, | ||
M | ||
> { | ||
constructor: EndpointConstructor; | ||
@@ -84,4 +89,4 @@ | ||
readonly schema: S extends undefined ? ResolveType<F> : S; | ||
private _schema: S; // TODO: remove once we don't care about FetchShape compatibility | ||
readonly schema: S extends undefined ? schema.SchemaClass<ResolveType<F>> : S; | ||
readonly _schema: S; // TODO: remove once we don't care about FetchShape compatibility | ||
@@ -104,3 +109,5 @@ fetch: F; | ||
): EndpointInstance< | ||
'fetch' extends keyof typeof options ? typeof options['fetch'] : E['fetch'], | ||
'fetch' extends keyof typeof options | ||
? Exclude<typeof options['fetch'], undefined> | ||
: E['fetch'], | ||
'schema' extends keyof typeof options | ||
@@ -107,0 +114,0 @@ ? typeof options['schema'] |
@@ -13,3 +13,3 @@ import { Schema, AbstractInstanceType } from '@rest-hooks/normalizr'; | ||
(...args: Parameters<F>): InferReturn<F, S>; | ||
key(parmas?: Readonly<Parameters<F>[0]>): string; | ||
key(...args: Parameters<F>): string; | ||
readonly sideEffect?: M; | ||
@@ -16,0 +16,0 @@ readonly schema?: S; |
Sorry, the diff of this file is not supported yet
71273
990