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

Can't import from JSON #200

Closed
CodeFromAnywhere opened this issue May 28, 2024 · 1 comment
Closed

Can't import from JSON #200

CodeFromAnywhere opened this issue May 28, 2024 · 1 comment

Comments

@CodeFromAnywhere
Copy link

CodeFromAnywhere commented May 28, 2024

This works

const x= {...} as const
type T =FromSchema<typeof x>

but this doesnt

import x from "./my-schema.json"
type T =FromSchema<typeof x>

is there something that can fix this? It would be much better for my usecase.

After some research, I think this would be needed to pass first: microsoft/TypeScript#32063

@ThomasAribart
Copy link
Owner

Hi @CodeFromAnywhere !

As you've seen, this is an issue with TypeScript rather than json-schema-to-ts, there is a page in the FAQ about it: https://github.com/ThomasAribart/json-schema-to-ts/blob/main/documentation/FAQs/does-json-schema-to-ts-work-on-json-file-schemas.md

TL:DR: There's not much we can do for the moment, just a small workaround which is not ideal.

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

2 participants