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

Support for inferred types #513

Closed
jonnyberanek opened this issue Sep 9, 2020 · 6 comments · Fixed by #1265
Closed

Support for inferred types #513

jonnyberanek opened this issue Sep 9, 2020 · 6 comments · Fixed by #1265
Labels
prerelease released This issue/pull request has been released.

Comments

@jonnyberanek
Copy link

Whenever trying to utilize inferred types, this error is thrown:

Error: Unknown node "FirestoreToSerializable<FirestoreService.CreateAuthor>" (ts.SyntaxKind = 184) at C:/proj-path/src/functions/admin/content/body.schema.d.ts(13,36)

After searching, it appears that SyntaxKind #184 is indeed InferType. After looking through the source code it appears that there is not a node parser for inferred types. I'm not too familiar with the inner workings of the project, what kind of additions would be needed to support inferred types?

@domoritz
Copy link
Member

domoritz commented Sep 9, 2020

You need to implement an InferTypeParser and then parse into the right type for it. The easiest way is to create a small test program and then use the debugger to step through the execution and fix where things fail.

@jirutka
Copy link
Contributor

jirutka commented Sep 18, 2020

Can you please give us some hints on how to implement InferTypeParser? I more or less understand how ts-json-schema-generator works, I have experiences with TypeScript AST, but I have no idea how to resolve inferted types.

@domoritz
Copy link
Member

Take a look at what properties InferType has.

Then take for example https://github.com/vega/ts-json-schema-generator/blob/master/src/NodeParser/AnyTypeNodeParser.ts. It knows how to handle a particular type, and then generates the correct type (here AnyType).

I haven't thought more about how exactly to handle InferType. That's an exercise fro the reader.

@jirutka
Copy link
Contributor

jirutka commented Sep 18, 2020

That's an exercise for the reader.

After reading this, I was quite sure that you’re from academia. And hey, you really are! 😄 So do I, sorta.

@domoritz
Copy link
Member

Hello, fellow academic.

I guess I should clarify that I mean "That's an exercise for the reader" somewhat sarcastically (because many books leave out too many steps when they use the phrase). There are actually a lot of steps left.

@github-actions
Copy link

🚀 Issue was released in v1.1.0 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prerelease released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants