Skip to content

$ref on definition and additionalProperties: false together results to never type #188

@tothdanielax

Description

@tothdanielax

I try to refer to a definition and after that make additionalProperties: false. The expected result would be a TS type without [x: string]: unknown;

Simplified example:

export const ciSchemaa = {
    type: "object",
    $defs: {
        ciBaseMetadata: {
            type: "object",
            properties: {
                ciId: {
                    type: "string",
                },
            },
            required: [
                "ciId",
            ]
        },
    },
    $ref: "#/$defs/ciBaseMetadata",
    additionalProperties: false
} as const satisfies JSONSchema;

export type Ci = FromSchema<typeof ciSchema> // never

It is possible to make it work if I already set additionalProperties:false in the definition, but curious if that could be done as the last step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions