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

constAsEnum not aways working in combination with strictNullChecks #588

Open
robaca opened this issue Jan 15, 2024 · 2 comments
Open

constAsEnum not aways working in combination with strictNullChecks #588

robaca opened this issue Jan 15, 2024 · 2 comments

Comments

@robaca
Copy link

robaca commented Jan 15, 2024

The following example still in one case generates const instead of enum:

type A = B | C

interface B {
    myProp?: false
}

interface C {
    myProp: true
}

When generating the schema like this:

typescript-json-schema --constAsEnum --strictNullChecks test.ts A

The outcome is:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "anyOf": [
        {
            "$ref": "#/definitions/B"
        },
        {
            "$ref": "#/definitions/C"
        }
    ],
    "definitions": {
        "B": {
            "properties": {
                "myProp": {
                    "const": false,
                    "type": "boolean"
                }
            },
            "type": "object"
        },
        "C": {
            "properties": {
                "myProp": {
                    "enum": [
                        true
                    ],
                    "type": "boolean"
                }
            },
            "type": "object"
        }
    }
}
@ruettenm
Copy link

@domoritz do you still maintain this package? Any thoughts about this problem?

@domoritz
Copy link
Collaborator

I don't use it anymore but merge PRs and make releases. I don't have time to triage or fix issues.

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

3 participants