openapi-codegen icon indicating copy to clipboard operation
openapi-codegen copied to clipboard

Binding element 'signal' implicitly has an 'any' type

Open calvinf opened this issue 3 years ago • 2 comments

In the generated code for components, I'm running into a problem due to our TypeScript configuration disallowing implicit any.

The error I get when running tsc as part of our build process:

src/generated/user/userComponents.ts:993:8 - error TS7031: Binding element 'signal' implicitly has an 'any' type.

993     ({ signal }) => fetchGetCurrentUser({ ...fetcherOptions, ...variables }, signal),

It looks like this single line could be fixed by setting a type on the signal property like:

({ signal }: { signal?: AbortSignal }) =>
      fetchGetCurrentUser({ ...fetcherOptions, ...variables }, signal),

Either that or defining a type like type SignalOption = { signal?: AbortSignal } and using that there.

Maybe there's a better way to do it to have the compiler infer the type for signal.

It would be nice to have the type explicitly defined to avoid this problem.

calvinf avatar Oct 20 '22 17:10 calvinf

Dependencies snippet:

    "@openapi-codegen/cli": "^2.0.0",
    "@openapi-codegen/typescript": "^6.0.0",

    "typescript": "^4.7.4",

calvinf avatar Oct 20 '22 17:10 calvinf

hi, @calvinf can you share your tsconfig? and what version are you using for @tanstack/react-query?

needim avatar Nov 10 '22 17:11 needim