rametta / rapini

:leafy_green: OpenAPI to React Query (or SWR) & Axios
Apache License 2.0
147 stars 17 forks source link

Type imports are not quite right #11

Closed bitttttten closed 1 year ago

bitttttten commented 2 years ago

Hello! I was testing out rapini but noticed that in the exported code, the type imports for TypeScript are just a little off:

import type { AxiosInstance, AxiosRequestConfig } from "axios";
import { useQuery, useMutation, useQueryClient, type QueryClient, type UseMutationOptions, type UseQueryOptions, type MutationFunction, type UseMutationResult, type UseQueryResult } from "react-query";

You can see how it's not handling theimport type syntax probably. I think should probably be

import type { AxiosInstance, AxiosRequestConfig } from "axios";
import { useQuery, useMutation, useQueryClient } from "react-query";
import type { QueryClient, UseMutationOptions, UseQueryOptions, MutationFunction, UseMutationResult, UseQueryResult } from "react-query";

Is that right?

rametta commented 2 years ago

@bitttttten it depends on the version of typescript, so the generated code is based on the more recent versions of typescript. But perhaps we should support some older versions of typescript so we don't leave out anyone. I'll keep this issue open to remind me to support the older versions of TS

bitttttten commented 2 years ago

Ohhh I had not come across this syntax before! Thanks for the explanation 👍

rametta commented 1 year ago

I'm going to close this issue for now. If anybody else really needs the old way of defining types, they can open a new issue or reply to this issue and we'll reopen this