openapi-ts / openapi-typescript

Generate TypeScript types from OpenAPI 3 specs

Home Page:https://openapi-ts.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.9.4 breaks some Typescript configurations

djMax opened this issue · comments

Description

Something in the changes in 0.9.4 causes NodeNext module resolution to fail.

#1634

Reproduction

Node.js side, but build time so no reason browser wouldn't also be affected. I can't get the playground to fail because I don't have full control of tsconfig it seems, but here's what fails in a local build with specific tsconfig values (as described in the discussion):

Playground

Expected result

URLs should be "known" but end up just being ignored/allow any value.

Checklist

Thanks for the investigation! Looking into it. It could have something to do with a change to openapi-typescript-helpers. I think I’m going to add tests for different moduleResolutions somehow. Could or could not be the problem based on #1634, but couldn’t hurt to eliminate that as a possibility. This seems like a bug, as TSConfig settings shouldn’t affect type safety.

Let me know if I can help - I had a sniff that the helpers might be involved too but I couldn't quite see how. There are a number of typing related changes in there, so it's a bit beyond my limited current understanding of the type infra here.

Is this theoretically fixed? I think it is but I have only seen that the playground errors now (as it should). But before I go through the variety of deps to update would love to know it was intentional :)

Running into exactly the same problem, currently stuck on 0.9.3, all versions afterwards lose all type information.

image

Whereas it used to work :)

image

Tried both openapi-typescript-helpers 0.0.7 and 0.0.8, no difference in the generated output together with openapi-typescript 6.7.6

My tsconfig.json has both module and moduleResolution set to NodeNext.

Investigated this a little further and in planning for the upcoming 0.10.0 release (which requires openapi-typescript@7.x which will also get a stable release at the same time) this is hopefully fixed. Or if not fixed, easier to debug.

I believe some of this came from openapi-typescript@6.x generating a lot of partial schemas, which made inference harder. 7.x generating full schemas with never types means openapi-fetch can get simpler inference, and easier cross-comparison since all shapes are fully outlined. Or that’s the hope, at least.

Some of the type inference that I believe led to the regression has been changed in 0.10.0. Are people still seeing the failures with the latest version?

Not resolved here.

Bumped both fetch and generator to latest, regenerated, but no types. Using nodenext.