Skip to content

Case where allOf is not included in compiled ts interface definition #47

Closed
@darcyparker

Description

@darcyparker

Have a look at: https://github.com/darcyparker/json-schema-to-typescript/blob/fe3f08f1d7eb4445619488974f9f89b2353b74c7/test/cases/allOf.ts

As a comparison, dtsgenerator creates this output:

export interface Itest {
    fooAndBar: {
        a: string;
        b: number;
    };
    foo: {
        a: string;
        b: number;
    };
    more: {
        a: string;
    };
}
declare namespace Itest {
    namespace Definitions {
        export interface Bar {
            a: string;
        }
        export interface Foo {
            a: string;
            b: number;
        }
    }
}

Notes:

  • ignore the interface name and namespace Itest...: dtgenerator uses the filename rather than the title of the schema.
  • I like json-schema-typescript's compiler's choice to use the definitions of Bar and Foo in Itest. but ignoring this, you can see it picks up the properties inside allOf that is a sibling of the top level properties. I believe this is correct behavior because ajv compile -s test.json -o test.js creates a validator that checks for more.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions