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
[REG 1.0->1.1] Omitted optional functions are throwing Error: Unknown type "function"
#1456
Comments
Confirming this issue is still present in v1.2.0 |
I can have a look, I personally use my own formatters: So constructors are also inclined to this type of issue. |
So, when can we solve it? |
@anymouschina maybe you can contribute a patch if you have time. On my side, I'll have a look when I can, this is not a top priority for me, but will try this week, as I need to check the typescript 5 migration |
@loopingz I have resolved my problem by referring to this link : |
@loopingz Issues is still present and looking into this issue would be highly appreciated 🙏 |
🚀 Issue was released in |
I have a simple User interface and try to create the schema. The User can have some functions, which won't work so there is a Jsonify type that will strip out the functions, this is adequate for my needs. Here is a simplified sample of a working TS file.
Now generate the schema with:
Outputs the schema as expected. All good 👍
However, now replace
getFullName
withgetFullName?
making it optional. Run the command again and we receive:But the VSCode TS hint shows the JSONUser does NOT contain the function:
This is a regression in v1.1.0, as v1.0.0 works. I have narrowed it down to the Typescript dependency which was upgraded in v1.1.0
https://github.com/vega/ts-json-schema-generator/pull/1388/files
TS v4.7.4 is fine, v4.8+ is not.
I have also tried many variations of the
Jsonify
type above, with all of the examples on SO:https://stackoverflow.com/questions/55479658/how-to-create-a-type-excluding-instance-methods-from-a-class-in-typescript
But they are all failing in the same way.
The text was updated successfully, but these errors were encountered: