This was an effort to create an MVP for a "bug" in
json-schema-to-typescript. Instead, I realized I could resolve it by
adding an @id
annotation to each exported interface.
$ make
npx typescript-json-schema \
--required \
--out schema.json \
tsconfig.json \
Data
$ make output.ts
npx json2ts \
-i schema.json \
-o output.ts
Comparing input.d.ts
to output.ts
we see very little difference:
--- input.d.ts 2019-03-24 16:37:54.000000000 -0700
+++ output.ts 2019-03-24 16:38:04.000000000 -0700
@@ -1,3 +1,10 @@
+/* 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.
+ */
+
/**
* A user provided answer.
*/
@@ -5,20 +12,13 @@
/**
* Simple data model.
- *
- * @additionalProperties false
- * @id Data
*/
export interface Data {
answer: Answer;
point?: Point;
}
-
/**
* Point in Euclidean space.
- *
- * @additionalProperties false
- * @id Point
*/
export interface Point {
x: number;