Skip to content
New issue

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

Remove redundant ParamsObj/SubscribeParamsObj types #105

Merged
1 commit merged into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,8 @@ const validParams: SharedParam[] = [

export type PreparedFn<T extends Dictionary<ParameterAlias>, U> = (
parameterAliases?: T,
body?: ParamsObj['body'],
passthrough?: ParamsObj['passthrough'],
body?: Params['body'],
passthrough?: Params['passthrough'],
) => U;

export type PromiseObj = Promise<{}>;
Expand Down Expand Up @@ -858,7 +858,7 @@ export abstract class PinejsClientCore<PinejsClient> {
return this.transformGetResult(params)(result);
}

protected transformGetResult(params: ParamsObj) {
protected transformGetResult(params: Params) {
const singular = params.id != null;

return (data: AnyObject): PromiseResultTypes => {
Expand Down Expand Up @@ -988,11 +988,11 @@ export abstract class PinejsClientCore<PinejsClient> {
}

public prepare<T extends Dictionary<ParameterAlias>>(
params: ParamsObj & { method?: 'GET' },
params: Params & { method?: 'GET' },
): PreparedFn<T, PromiseResult>;
public prepare<T extends Dictionary<ParameterAlias>>(
params: ParamsObj & {
method: Exclude<ParamsObj['method'], 'GET'>;
params: Params & {
method: Exclude<Params['method'], 'GET'>;
},
): PreparedFn<T, PromiseObj>;
public prepare<T extends Dictionary<ParameterAlias>>(
Expand Down Expand Up @@ -1331,7 +1331,7 @@ type SharedParam = 'apiPrefix' | 'passthrough' | 'passthroughByMethod';

export type AnyObject = Dictionary<any>;

interface ParamsObj {
export interface Params {
apiPrefix?: string;
method?: ODataMethod;
resource?: string;
Expand All @@ -1343,15 +1343,12 @@ interface ParamsObj {
options?: ODataOptions;
}

export type Params = ParamsObj;

interface SubscribeParamsObj extends ParamsObj {
export interface SubscribeParams extends Params {
method?: 'GET';
pollInterval?: number;
}
export type SubscribeParams = SubscribeParamsObj;

export interface UpsertParams extends Omit<ParamsObj, 'id' | 'method'> {
export interface UpsertParams extends Omit<Params, 'id' | 'method'> {
id: Dictionary<Primitive>;
resource: string;
body: AnyObject;
Expand Down