ThomasAribart / json-schema-to-ts

Infer TS types from JSON schemas 📝
MIT License
1.43k stars 30 forks source link

Non-strict TS compiler config leads to not resolved refs #145

Closed codeliner closed 8 months ago

codeliner commented 1 year ago

Hey @ThomasAribart, first of all thank you for this amazing piece of work. I did not expect that something like this is possible with TS. It feels like black magic, but in a good way ;)

I'd like to suggest one FAQ addition:

Not sure if I missed it in the docs, but I ran into an issue with ref resolving and it took me a couple of hours to figure out what's wrong. I've set up a new project with the help of Nx, but missed the point that Nx by default creates a tsconfig without

"compilerOptions": {
  "strict": true,  // <-- missing flag
  ...
}

json-schema-to-ts worked as normal (used it in other projects already) until I added a $ref to a schema. Even thought I did exactly the same as in other projects, it did not resolve the references passed as option to FromSchema.

Enabling TS compiler strict mode solved the issue.

Is this known behavior? Is it worth to add it to the FAQ section of the readme?

ThomasAribart commented 8 months ago

Hi @codeliner !

Yes it is known, and is already mentioned in the installation section 👍 I can make it clearer though.