json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

Generated types of referenced schemas are not imported

Open AndyOGo opened this issue 3 years ago • 3 comments

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

{
  [k: string]: unknown;
}

maybe related #471

AndyOGo avatar Jul 30 '22 16:07 AndyOGo

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

AndyOGo avatar Jul 30 '22 17:07 AndyOGo

Mind adding a self contained repro?

bcherny avatar Aug 06 '22 08:08 bcherny

@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;
};

ianwremmel avatar Sep 12 '22 03:09 ianwremmel