openapi-generator-plus-generators icon indicating copy to clipboard operation
openapi-generator-plus-generators copied to clipboard

typescript-fetch-client2 - generated code doesn't compile with noUnusedLocals

Open taras opened this issue 3 years ago • 2 comments

Related: https://github.com/karlvr/openapi-generator-plus/issues/34

Backstage projects use this config https://github.com/backstage/backstage/blob/master/packages/cli/config/tsconfig.json which includes noUnusedLocals: true.

When I try to compile the project with code generated by typescript-fetch-client2, I get the following errors,

  • error TS6133: 'COLLECTION_FORMATS' is declared but its value is never read.
  • error TS6133: 'configuration' is declared but its value is never read.
  • error TS6133: 'mimeType' is declared but its value is never read.
  • error TS6133: 'dateToString' is declared but its value is never read.

Is it possible to detect when these are not necessary and not generating them?

taras avatar Mar 05 '22 16:03 taras

@taras thanks for posting this. It's one of those tricky things that I feel can overly complicate the templates to check... I've previously been cheeky with linting and added overrides. Do you know if it's possible to override noUnusedLocals in a particular file? What do you reckon?

karlvr avatar Mar 08 '22 05:03 karlvr

I tried. I'm not able to override it because Backstage projects are a monorepo with tsconfig.json at the root. I created an example project to show you https://github.com/taras/backstage-openapi-client-scaffolding

taras avatar Mar 08 '22 14:03 taras