Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

@effect/openapi-generator: generated output triggers the language service `schemaNumber` and `unnecessaryTypeofType` diagnostics

Cerrado
#7,646 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Ya se ha fusionado un pull request relacionado.

  • #7647 de @Stanzilla — cerrado sin fusionar
  • #9694 de @effect-bot — fusionado

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
openapi, typescript
Área
api, tooling

Línea de trabajo

Start at the @effect/openapi-generator path handling generator.generate with format: 'httpclient', using the minimal OpenAPI spec in the issue to reproduce the output. Check generated number schemas and operation response types against the language-service diagnostics, then verify the output also avoids the reported unused decodeError case under noUnusedLocals.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

The httpclient output of @effect/openapi-generator 4.0.0-rc.112 is flagged by @effect/language-service (via @effect/tsgo 0.38.0) with two suggestion diagnostics that the generator could avoid by construction.

Reproduction (spec in the collapsed block below, format: 'httpclient'):

const generator = await Effect.runPromise(OpenApiGenerator.make);
const out = await Effect.runPromise(
  generator.generate(spec, { name: 'ReproClient', format: 'httpclient' }),
);

Generated (abridged):

export const Addon = Schema.Struct({
  "id": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
  "downloads": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
})
// ...
readonly "getAddon": <Config extends OperationConfig>(id: string, options: ...) =>
  Effect.Effect<WithOptionalResponse<typeof GetAddon200.Type, Config>, HttpClientError.HttpClientError | SchemaError>

tsc with the language-service plugin reports:

repro.ts(11,51): suggestion TS377098: This Schema number API accepts `NaN`, `Infinity`, and `-Infinity`. Use `Schema.Finite` for finite domain numbers. ... effect(schemaNumber)
repro.ts(11,140): suggestion TS377098: ... effect(schemaNumber)
repro.ts(98,170): suggestion TS377090: This `typeof ... .Type` query can be replaced with `GetAddon200`. effect(unnecessaryTypeofType)

Expected

  1. Numbers from JSON are always finite, so Schema.Finite (and Schema.Int for type: integer) would satisfy schemaNumber. The generator already appends Schema.isFinite() for number, so the intent is there; only the base schema differs.
  2. Operation signatures reference typeof X.Type even though the generator emits export type X = ... for the same name in the same file. Emitting X would satisfy unnecessaryTypeofType.

Since both tools live in this monorepo, it would be good for the generator's default output to pass the language service's defaults. We currently post-process the output (replace Schema.Number with Schema.Finite, and typeof X.Type with X when the alias exists), which works but should not be necessary.

Side observation: for a spec with no error responses, the generated client declares decodeError without using it, which fails under noUnusedLocals (TS6133).

Minimal spec
{
  "openapi": "3.0.0",
  "info": { "title": "Repro", "version": "1.0.0" },
  "paths": {
    "/addons/{id}": {
      "get": {
        "operationId": "getAddon",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Addon" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Addon": {
        "type": "object",
        "required": ["id", "downloads"],
        "properties": { "id": { "type": "integer" }, "downloads": { "type": "number" } }
      }
    }
  }
}

Versions: @effect/openapi-generator 4.0.0-rc.112, effect 4.0.0-rc.112, @effect/tsgo 0.38.0.

Lenguaje dominante
TypeScript
Estrellas
16.7k
Forks
808
Merge medio
10 h 13 min
PR fusionados (30 d)
800

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Effect-TS/effect

Todos los issues de Effect-TS/effect

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.