From e7b94579ca0604d2fcf69541d8a185b552ec288a Mon Sep 17 00:00:00 2001 From: Landon Gavin Date: Mon, 29 Apr 2024 18:05:42 -0400 Subject: [PATCH] feat: add query key function --- README.md | 69 ++++++++ examples/react-app/src/App.tsx | 4 +- src/common.mts | 8 + src/createExports.mts | 7 +- src/createUseQuery.mts | 159 +++++++++++++----- tests/__snapshots__/createSource.test.ts.snap | 20 ++- tests/__snapshots__/generate.test.ts.snap | 20 ++- tests/createExports.test.ts | 13 +- 8 files changed, 239 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 52ff462..37de013 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,75 @@ function App() { export default App; ``` +##### Using Mutation hooks + +```tsx +// App.tsx +import { usePetServiceAddPet } from "../openapi/queries"; + +function App() { + const { mutate } = usePetServiceAddPet(); + + const handleAddPet = () => { + mutate({ name: "Fluffy", status: "available" }); + }; + + return ( +
+

Add Pet

+ +
+ ); +} + +export default App; +``` + +##### Invalidating queries after mutation + +Invalidating queries after a mutation is important to ensure the cache is updated with the new data. This is done by calling the `queryClient.invalidateQueries` function with the query key used by the query hook. + +Learn more about invalidating queries [here](https://tanstack.com/query/latest/docs/framework/react/guides/query-invalidation). + +To ensure the query key is created the same way as the query hook, you can use the query key function exported by the generated query hooks. + +```tsx +import { + usePetServiceFindPetsByStatus, + usePetServiceAddPet, + UsePetServiceFindPetsByStatusKeyFn, +} from "../openapi/queries"; + +// App.tsx +function App() { + const { data } = usePetServiceFindPetsByStatus({ status: ["available"] }); + const { mutate } = usePetServiceAddPet({ + onSuccess: () => { + queryClient.invalidateQueries({ + // Call the query key function to get the query key, this is important to ensure the query key is created the same way as the query hook, this insures the cache is invalidated correctly and is typed correctly + queryKey: [UsePetServiceFindPetsByStatusKeyFn()], + }); + }, + }); + + return ( +
+

Pet List

+ + +
+ ); +} + +export default App; +``` + ##### Runtime Configuration You can modify the default values used by the generated service calls by modifying the OpenAPI configuration singleton object. diff --git a/examples/react-app/src/App.tsx b/examples/react-app/src/App.tsx index 6d280c1..c0712fc 100644 --- a/examples/react-app/src/App.tsx +++ b/examples/react-app/src/App.tsx @@ -2,7 +2,7 @@ import "./App.css"; import { useDefaultServiceAddPet, useDefaultServiceFindPets, - useDefaultServiceFindPetsKey, + UseDefaultServiceFindPetsKeyFn, useDefaultServiceGetNotDefined, useDefaultServicePostNotDefined, } from "../openapi/queries"; @@ -54,7 +54,7 @@ function App() { { onSuccess: () => { queryClient.invalidateQueries({ - queryKey: [useDefaultServiceFindPetsKey], + queryKey: UseDefaultServiceFindPetsKeyFn(), }); console.log("success"); }, diff --git a/src/common.mts b/src/common.mts index 2f28a5d..9ea2709 100644 --- a/src/common.mts +++ b/src/common.mts @@ -15,6 +15,14 @@ export const TData = ts.factory.createIdentifier("TData"); export const TError = ts.factory.createIdentifier("TError"); export const TContext = ts.factory.createIdentifier("TContext"); +export const EqualsOrGreaterThanToken = ts.factory.createToken( + ts.SyntaxKind.EqualsGreaterThanToken +); + +export const QuestionToken = ts.factory.createToken( + ts.SyntaxKind.QuestionToken +); + export const queryKeyGenericType = ts.factory.createTypeReferenceNode("TQueryKey"); export const queryKeyConstraint = ts.factory.createTypeReferenceNode("Array", [ diff --git a/src/createExports.mts b/src/createExports.mts index aad6c0b..5d9bf1f 100644 --- a/src/createExports.mts +++ b/src/createExports.mts @@ -40,7 +40,12 @@ export const createExports = (service: Service) => { ]; const commonInQueries = allQueries - .map(({ apiResponse, returnType, key }) => [apiResponse, returnType, key]) + .map(({ apiResponse, returnType, key, queryKeyFn }) => [ + apiResponse, + returnType, + key, + queryKeyFn, + ]) .flat(); const commonInMutations = allMutations .map(({ mutationResult }) => [mutationResult]) diff --git a/src/createUseQuery.mts b/src/createUseQuery.mts index ef9d2b2..34554a3 100644 --- a/src/createUseQuery.mts +++ b/src/createUseQuery.mts @@ -3,11 +3,13 @@ import { MethodDeclaration } from "ts-morph"; import { BuildCommonTypeName, capitalizeFirstLetter, + EqualsOrGreaterThanToken, extractPropertiesFromObjectParam, getNameFromMethod, getShortType, queryKeyConstraint, queryKeyGenericType, + QuestionToken, TData, TError, } from "./common.mjs"; @@ -61,12 +63,15 @@ export const createApiResponseType = ({ ); return { - /** DefaultResponseDataType + /** + * DefaultResponseDataType + * * export type MyClassMethodDefaultResponse = Awaited> */ apiResponse, /** - * will be the name of the type of the response type of the method + * This will be the name of the type of the response type of the method + * * MyClassMethodDefaultResponse */ responseDataType, @@ -128,6 +133,7 @@ export function getRequestParamFromMethod(method: MethodDeclaration) { /** * Return Type + * * export const classNameMethodNameQueryResult = UseQueryResult; */ export function createReturnTypeExport({ @@ -311,7 +317,7 @@ export function createQueryHook({ ), ], undefined, - ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + EqualsOrGreaterThanToken, ts.factory.createCallExpression( ts.factory.createIdentifier(queryString), [ @@ -322,41 +328,28 @@ export function createQueryHook({ ts.factory.createObjectLiteralExpression([ ts.factory.createPropertyAssignment( ts.factory.createIdentifier("queryKey"), - ts.factory.createArrayLiteralExpression( - [ - BuildCommonTypeName(queryKey), - ts.factory.createSpreadElement( - ts.factory.createParenthesizedExpression( - ts.factory.createBinaryExpression( - ts.factory.createIdentifier("queryKey"), - ts.factory.createToken( - ts.SyntaxKind.QuestionQuestionToken - ), - method.getParameters().length - ? ts.factory.createArrayLiteralExpression([ - ts.factory.createObjectLiteralExpression( - method - .getParameters() - .map((param) => - extractPropertiesFromObjectParam( - param - ).map((p) => - ts.factory.createShorthandPropertyAssignment( - ts.factory.createIdentifier( - p.name - ) - ) - ) - ) - .flat() - ), - ]) - : ts.factory.createArrayLiteralExpression([]) - ) - ) - ), - ], - false + ts.factory.createCallExpression( + BuildCommonTypeName(getQueryKeyFnName(queryKey)), + undefined, + + method.getParameters().length + ? [ + ts.factory.createObjectLiteralExpression( + method + .getParameters() + .map((param) => + extractPropertiesFromObjectParam(param).map( + (p) => + ts.factory.createShorthandPropertyAssignment( + ts.factory.createIdentifier(p.name) + ) + ) + ) + .flat() + ), + ts.factory.createIdentifier("queryKey"), + ] + : [] ) ), ts.factory.createPropertyAssignment( @@ -366,9 +359,7 @@ export function createQueryHook({ undefined, [], undefined, - ts.factory.createToken( - ts.SyntaxKind.EqualsGreaterThanToken - ), + EqualsOrGreaterThanToken, ts.factory.createAsExpression( ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression( @@ -463,11 +454,97 @@ export const createUseQuery = ({ queryKey, }); + const queryKeyFn = createQueryKeyFnExport(queryKey, method); + return { apiResponse: defaultApiResponse, returnType: returnTypeExport, key: queryKeyExport, queryHook: hookWithJsDoc, suspenseQueryHook: suspenseHookWithJsDoc, + queryKeyFn, }; }; + +function getQueryKeyFnName(queryKey: string) { + return `${capitalizeFirstLetter(queryKey)}Fn`; +} + +function createQueryKeyFnExport(queryKey: string, method: MethodDeclaration) { + const params = getRequestParamFromMethod(method); + + // override key is used to allow the user to override the the queryKey values + const overrideKey = ts.factory.createParameterDeclaration( + undefined, + undefined, + ts.factory.createIdentifier("queryKey"), + QuestionToken, + ts.factory.createTypeReferenceNode("Array", []) + ); + + return ts.factory.createVariableStatement( + [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], + ts.factory.createVariableDeclarationList( + [ + ts.factory.createVariableDeclaration( + ts.factory.createIdentifier(getQueryKeyFnName(queryKey)), + undefined, + undefined, + ts.factory.createArrowFunction( + undefined, + undefined, + params ? [params, overrideKey] : [], + undefined, + EqualsOrGreaterThanToken, + queryKeyFn(queryKey, method) + ) + ), + ], + ts.NodeFlags.Const + ) + ); +} + +function queryKeyFn( + queryKey: string, + method: MethodDeclaration +): ts.Expression { + const params = getRequestParamFromMethod(method); + + if (!params) { + return ts.factory.createArrayLiteralExpression([ + ts.factory.createIdentifier(queryKey), + ]); + } + + return ts.factory.createArrayLiteralExpression( + [ + ts.factory.createIdentifier(queryKey), + ts.factory.createSpreadElement( + ts.factory.createParenthesizedExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("queryKey"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + method.getParameters().length + ? ts.factory.createArrayLiteralExpression([ + ts.factory.createObjectLiteralExpression( + method + .getParameters() + .map((param) => + extractPropertiesFromObjectParam(param).map((p) => + ts.factory.createShorthandPropertyAssignment( + ts.factory.createIdentifier(p.name) + ) + ) + ) + .flat() + ), + ]) + : ts.factory.createArrayLiteralExpression([]) + ) + ) + ), + ], + false + ); +} diff --git a/tests/__snapshots__/createSource.test.ts.snap b/tests/__snapshots__/createSource.test.ts.snap index 9ab2bcb..c482300 100644 --- a/tests/__snapshots__/createSource.test.ts.snap +++ b/tests/__snapshots__/createSource.test.ts.snap @@ -17,12 +17,20 @@ import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; export type DefaultServiceFindPetsDefaultResponse = Awaited>; export type DefaultServiceFindPetsQueryResult = UseQueryResult; export const useDefaultServiceFindPetsKey = "DefaultServiceFindPets"; +export const UseDefaultServiceFindPetsKeyFn = ({ limit, tags }: { + limit?: number; + tags?: string[]; +} = {}, queryKey?: Array) => [useDefaultServiceFindPetsKey, ...(queryKey ?? [{ limit, tags }])]; export type DefaultServiceGetNotDefinedDefaultResponse = Awaited>; export type DefaultServiceGetNotDefinedQueryResult = UseQueryResult; export const useDefaultServiceGetNotDefinedKey = "DefaultServiceGetNotDefined"; +export const UseDefaultServiceGetNotDefinedKeyFn = () => [useDefaultServiceGetNotDefinedKey]; export type DefaultServiceFindPetByIdDefaultResponse = Awaited>; export type DefaultServiceFindPetByIdQueryResult = UseQueryResult; export const useDefaultServiceFindPetByIdKey = "DefaultServiceFindPetById"; +export const UseDefaultServiceFindPetByIdKeyFn = ({ id }: { + id: number; +}, queryKey?: Array) => [useDefaultServiceFindPetByIdKey, ...(queryKey ?? [{ id }])]; export type DefaultServiceAddPetMutationResult = Awaited>; export type DefaultServicePostNotDefinedMutationResult = Awaited>; export type DefaultServiceDeletePetMutationResult = Awaited>; @@ -52,14 +60,14 @@ import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; export const useDefaultServiceFindPets = = unknown[]>({ limit, tags }: { limit?: number; tags?: string[]; -} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: [Common.useDefaultServiceFindPetsKey, ...(queryKey ?? [{ limit, tags }])], queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); +} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: Common.UseDefaultServiceFindPetsKeyFn({ limit, tags }, queryKey), queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); /** * @deprecated * This path is not fully defined. * @returns unknown unexpected error * @throws ApiError */ -export const useDefaultServiceGetNotDefined = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: [Common.useDefaultServiceGetNotDefinedKey, ...(queryKey ?? [])], queryFn: () => DefaultService.getNotDefined() as TData, ...options }); +export const useDefaultServiceGetNotDefined = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: Common.UseDefaultServiceGetNotDefinedKeyFn(), queryFn: () => DefaultService.getNotDefined() as TData, ...options }); /** * Returns a user based on a single ID, if the user does not have access to the pet * @param data The data for the request. @@ -70,7 +78,7 @@ export const useDefaultServiceGetNotDefined = = unknown[]>({ id }: { id: number; -}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: [Common.useDefaultServiceFindPetByIdKey, ...(queryKey ?? [{ id }])], queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); +}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: Common.UseDefaultServiceFindPetByIdKeyFn({ id }, queryKey), queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); /** * Creates a new pet in the store. Duplicates are allowed * @param data The data for the request. @@ -130,14 +138,14 @@ import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; export const useDefaultServiceFindPetsSuspense = = unknown[]>({ limit, tags }: { limit?: number; tags?: string[]; -} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: [Common.useDefaultServiceFindPetsKey, ...(queryKey ?? [{ limit, tags }])], queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); +} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: Common.UseDefaultServiceFindPetsKeyFn({ limit, tags }, queryKey), queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); /** * @deprecated * This path is not fully defined. * @returns unknown unexpected error * @throws ApiError */ -export const useDefaultServiceGetNotDefinedSuspense = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: [Common.useDefaultServiceGetNotDefinedKey, ...(queryKey ?? [])], queryFn: () => DefaultService.getNotDefined() as TData, ...options }); +export const useDefaultServiceGetNotDefinedSuspense = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: Common.UseDefaultServiceGetNotDefinedKeyFn(), queryFn: () => DefaultService.getNotDefined() as TData, ...options }); /** * Returns a user based on a single ID, if the user does not have access to the pet * @param data The data for the request. @@ -148,7 +156,7 @@ export const useDefaultServiceGetNotDefinedSuspense = = unknown[]>({ id }: { id: number; -}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: [Common.useDefaultServiceFindPetByIdKey, ...(queryKey ?? [{ id }])], queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); +}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: Common.UseDefaultServiceFindPetByIdKeyFn({ id }, queryKey), queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); " `; diff --git a/tests/__snapshots__/generate.test.ts.snap b/tests/__snapshots__/generate.test.ts.snap index b62daa0..d08bee3 100644 --- a/tests/__snapshots__/generate.test.ts.snap +++ b/tests/__snapshots__/generate.test.ts.snap @@ -8,12 +8,20 @@ import { DefaultService } from "../requests/services.gen"; export type DefaultServiceFindPetsDefaultResponse = Awaited>; export type DefaultServiceFindPetsQueryResult = UseQueryResult; export const useDefaultServiceFindPetsKey = "DefaultServiceFindPets"; +export const UseDefaultServiceFindPetsKeyFn = ({ limit, tags }: { + limit?: number; + tags?: string[]; +} = {}, queryKey?: Array) => [useDefaultServiceFindPetsKey, ...(queryKey ?? [{ limit, tags }])]; export type DefaultServiceGetNotDefinedDefaultResponse = Awaited>; export type DefaultServiceGetNotDefinedQueryResult = UseQueryResult; export const useDefaultServiceGetNotDefinedKey = "DefaultServiceGetNotDefined"; +export const UseDefaultServiceGetNotDefinedKeyFn = () => [useDefaultServiceGetNotDefinedKey]; export type DefaultServiceFindPetByIdDefaultResponse = Awaited>; export type DefaultServiceFindPetByIdQueryResult = UseQueryResult; export const useDefaultServiceFindPetByIdKey = "DefaultServiceFindPetById"; +export const UseDefaultServiceFindPetByIdKeyFn = ({ id }: { + id: number; +}, queryKey?: Array) => [useDefaultServiceFindPetByIdKey, ...(queryKey ?? [{ id }])]; export type DefaultServiceAddPetMutationResult = Awaited>; export type DefaultServicePostNotDefinedMutationResult = Awaited>; export type DefaultServiceDeletePetMutationResult = Awaited>; @@ -94,14 +102,14 @@ import * as Common from "./common"; export const useDefaultServiceFindPets = = unknown[]>({ limit, tags }: { limit?: number; tags?: string[]; -} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: [Common.useDefaultServiceFindPetsKey, ...(queryKey ?? [{ limit, tags }])], queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); +} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: Common.UseDefaultServiceFindPetsKeyFn({ limit, tags }, queryKey), queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); /** * @deprecated * This path is not fully defined. * @returns unknown unexpected error * @throws ApiError */ -export const useDefaultServiceGetNotDefined = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: [Common.useDefaultServiceGetNotDefinedKey, ...(queryKey ?? [])], queryFn: () => DefaultService.getNotDefined() as TData, ...options }); +export const useDefaultServiceGetNotDefined = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: Common.UseDefaultServiceGetNotDefinedKeyFn(), queryFn: () => DefaultService.getNotDefined() as TData, ...options }); /** * Returns a user based on a single ID, if the user does not have access to the pet * @param data The data for the request. @@ -112,7 +120,7 @@ export const useDefaultServiceGetNotDefined = = unknown[]>({ id }: { id: number; -}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: [Common.useDefaultServiceFindPetByIdKey, ...(queryKey ?? [{ id }])], queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); +}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useQuery({ queryKey: Common.UseDefaultServiceFindPetByIdKeyFn({ id }, queryKey), queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); /** * Creates a new pet in the store. Duplicates are allowed * @param data The data for the request. @@ -171,14 +179,14 @@ import * as Common from "./common"; export const useDefaultServiceFindPetsSuspense = = unknown[]>({ limit, tags }: { limit?: number; tags?: string[]; -} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: [Common.useDefaultServiceFindPetsKey, ...(queryKey ?? [{ limit, tags }])], queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); +} = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: Common.UseDefaultServiceFindPetsKeyFn({ limit, tags }, queryKey), queryFn: () => DefaultService.findPets({ limit, tags }) as TData, ...options }); /** * @deprecated * This path is not fully defined. * @returns unknown unexpected error * @throws ApiError */ -export const useDefaultServiceGetNotDefinedSuspense = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: [Common.useDefaultServiceGetNotDefinedKey, ...(queryKey ?? [])], queryFn: () => DefaultService.getNotDefined() as TData, ...options }); +export const useDefaultServiceGetNotDefinedSuspense = = unknown[]>(queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: Common.UseDefaultServiceGetNotDefinedKeyFn(), queryFn: () => DefaultService.getNotDefined() as TData, ...options }); /** * Returns a user based on a single ID, if the user does not have access to the pet * @param data The data for the request. @@ -189,6 +197,6 @@ export const useDefaultServiceGetNotDefinedSuspense = = unknown[]>({ id }: { id: number; -}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: [Common.useDefaultServiceFindPetByIdKey, ...(queryKey ?? [{ id }])], queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); +}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">) => useSuspenseQuery({ queryKey: Common.UseDefaultServiceFindPetByIdKeyFn({ id }, queryKey), queryFn: () => DefaultService.findPetById({ id }) as TData, ...options }); " `; diff --git a/tests/createExports.test.ts b/tests/createExports.test.ts index 507b9cb..65b42d6 100644 --- a/tests/createExports.test.ts +++ b/tests/createExports.test.ts @@ -5,7 +5,7 @@ import { createExports } from "../src/createExports.mts"; import { getServices } from "../src/service.mts"; import path from "path"; -const fileName = "createExports" +const fileName = "createExports"; describe(fileName, () => { beforeAll(async () => await generateTSClients(fileName)); @@ -15,12 +15,12 @@ describe(fileName, () => { const project = new Project({ skipAddingFilesFromTsConfig: true, }); - project.addSourceFilesAtPaths(path.join(outputPath(fileName), '**', '*')); + project.addSourceFilesAtPaths(path.join(outputPath(fileName), "**", "*")); const service = await getServices(project); const exports = createExports(service); const commonTypes = exports.allCommon - .filter((c) => c.kind === SyntaxKind.TypeAliasDeclaration) + .filter((c) => c.kind === SyntaxKind.TypeAliasDeclaration) // @ts-ignore .map((e) => e.name.escapedText); expect(commonTypes).toStrictEqual([ @@ -36,13 +36,16 @@ describe(fileName, () => { ]); const constants = exports.allCommon - .filter((c) => c.kind === SyntaxKind.VariableStatement) - // @ts-ignore + .filter((c) => c.kind === SyntaxKind.VariableStatement) + // @ts-ignore .map((c) => c.declarationList.declarations[0].name.escapedText); expect(constants).toStrictEqual([ "useDefaultServiceFindPetsKey", + "UseDefaultServiceFindPetsKeyFn", "useDefaultServiceGetNotDefinedKey", + "UseDefaultServiceGetNotDefinedKeyFn", "useDefaultServiceFindPetByIdKey", + "UseDefaultServiceFindPetByIdKeyFn", ]); const mainExports = exports.mainExports.map(