bcherny / json-schema-to-typescript

Compile JSON Schema to TypeScript type declarations
https://bcherny.github.io/json-schema-to-typescript-browser/
MIT License
2.95k stars 393 forks source link

Generated types of referenced schemas are not imported #476

Open AndyOGo opened 2 years ago

AndyOGo commented 2 years ago

Generated types of referenced schemas are not imported, instead they are output as:

{
  [k: string]: unknown;
}

maybe related #471

AndyOGo commented 2 years ago

I fixed the { [k: string]: unknown; } with oneOf.

Though the types are still not imported, but instead included and duplicated in each file.

Sp probably related to #476

bcherny commented 2 years ago

Mind adding a self contained repro?

ianwremmel commented 2 years ago

@bcherny I think I'm running into the same issue

Using npx json2ts infile.json outfile.ts, this schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "allOf": [
    {
      "$ref": "https://json.schemastore.org/package.json"
    }
  ]
}

produces this typedef:

/* tslint:disable */
/**
 * This file was automatically generated by json-schema-to-typescript.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
 * and run json-schema-to-typescript to regenerate this file.
 */

export type Package = JSONSchemaForNPMPackageJsonFiles;
export type JSONSchemaForNPMPackageJsonFiles = {
  [k: string]: unknown;
};