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

v4: types fixes #64

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
InferResultFromBlock,
InferParamsInFromBlock,
InferBlock,
InferHttpBlock,
} from './types';
import type BaseBlock from './block';
import type { DescriptHttpBlockDescription, DescriptHttpBlockQuery, DescriptHttpBlockQueryValue } from './httpBlock';
Expand Down Expand Up @@ -205,6 +206,6 @@ export {
DescriptBlockDeps,
BaseBlock,
BlockResultOut,

InferHttpBlock,
HttpBlock,
};
8 changes: 8 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type DescriptLogger from './logger';
import type { IncomingHttpHeaders } from 'http';
import type { EventTimestamps } from './logger';
import type { RequestOptions } from './request';
import type HttpBlock from './httpBlock';

export interface DescriptHttpBlockResult<Result> {
statusCode: number;
Expand Down Expand Up @@ -122,6 +123,13 @@ infer Context, infer CustomBlock, infer ParamsOut, infer ResultOut, infer Interm
infer BlockResult, infer BeforeResultOut, infer AfterResultOut, infer ErrorResultOut, infer Params
> ? Type : never;

export type InferHttpBlock<Type> = Type extends HttpBlock<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
infer Context, infer ParamsOut, infer HttpResult, infer ResultOut, infer BlockResult,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
infer BeforeResultOut, infer AfterResultOut, infer ErrorResultOut, infer Params
> ? Type : never;

export type InferContextFromBlock< T > = T extends BaseBlock<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
infer Context, infer CustomBlock, infer ParamsOut, infer ResultOut, infer IntermediateResult,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "descript",
"description": "descript",
"version": "3.4.0",
"version": "3.4.1",
"homepage": "https://github.com/pasaran/descript3",
"repository": {
"type": "git",
Expand Down
Loading