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

[oats-runtime] TS6133: types and RequestContext is declared but its value is never read. #468

Open
serbanghita opened this issue Sep 12, 2024 · 2 comments

Comments

@serbanghita
Copy link

Problem:

A openapi.yaml file containing only models (schemas) and no urls, will generate a client.ts file what throws TS6133 in the context of tsconfig.json configured with

     "noUnusedLocals": true,
    "noUnusedParameters": true,  

This will cause builds that are using the generated code to fail at compile time.

How to reproduce:

Create openapi.yaml file with the following contents:

openapi: 3.0.0
info:
  title: A test without urls
  version: 0.0.1
  description: Types for
servers: []
paths: {}

components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string

Run generate.js which contains the boilerplate code from README.md:

TS6133: types is declared but its value is never read.
TS6133: RequestContext is declared but its value is never read.

Screenshot 2024-09-12 at 10 05 53

@serbanghita serbanghita changed the title TS6133: types and RequestContext is declared but its value is never read. [oats-runtime] TS6133: types and RequestContext is declared but its value is never read. Sep 12, 2024
@serbanghita
Copy link
Author

serbanghita commented Sep 12, 2024

According to microsoft/TypeScript#12913 one solution would be to add // @ts-ignore or // @ts-nocheck (optionally) on top of the generated file.

@serbanghita
Copy link
Author

Immediate solution:

header: ['// @ts-nocheck', '/* tslint:disable variable-name only-arrow-functions*/'].join("\n"),

Programmatic solution:

How about:

  1. adding // @ts-expect-error above EndpointsWithContext variable node
  2. adding // @ts-expect-error node above const types = generateImport('types', typemodule);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant