bcherny/json-schema-to-typescript

Feature request: dedupe emitted types referenced from multiple files

Open

#258 opened on Sep 17, 2019

View on GitHub
 (17 comments) (58 reactions) (0 assignees)TypeScript (449 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (3,302 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Apologies if this has been asked before, I did a few searches but couldn't quite find this.

I have a directory of schemas. Each of those schemas sometimes share references to common definitions.

This tool automatically expands the references, and they all get in-lined (and thus duplicated). It would be nice if references could be transformed to a typescript type, and referenced from a common file.

For example, 2 files might use:

{
  "myProp": { "$ref": "defs/my-prop.json" }
}

It would be really great if this were transformed to:

import { MyProp } from './defs/my-prop';

interface SomeObj {
  myProp: MyProp
}

Contributor guide