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

fix: ApiOptions intellisense #9

Merged
merged 1 commit into from
Mar 26, 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
17 changes: 15 additions & 2 deletions lib/api-specification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ const bindTrailArgs = (fn: Function, ...bound_args: any[]) => {
};
};

import { ApiExtraModels, ApiOperation, ApiResponse } from "@nestjs/swagger";
import { ApiSpecification } from "./api-specification";
import {
ApiExtraModels,
ApiOperation,
ApiQueryOptions,
ApiResponse,
} from "@nestjs/swagger";
import { ApiOptions, ApiSpecification } from "./api-specification";

// Mock specific decorator factory to return their params instead of decorator itself
jest.mock("@nestjs/swagger", () => ({
Expand Down Expand Up @@ -323,3 +328,11 @@ describe("ApiSpecification", () => {
});
});
});

describe("ApiOptions", () => {
it("intellisense should work", () => {
const options: ApiOptions = {
apiQueryOptions: (apiDecorator) => [],
};
});
});
6 changes: 3 additions & 3 deletions lib/api-specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ type ApiDecoratorFactories = {
: never]: NestJsSwaggerMethods[K];
};

type OrderSuffix = `${number}` | "";

export type ApiOptions = {
[K in keyof ApiDecoratorFactories as `${Uncapitalize<K>}Options${string}`]?: (
[K in keyof ApiDecoratorFactories as `${Uncapitalize<K>}Options${
| number
| ""}`]?: (
apiDecorator: ApiDecoratorFactories[K] & { brand: K },
) =>
| ReturnType<ApiDecoratorFactories[K] & { brand: K }>
Expand Down
Loading