diff --git a/base/flow/test/inputs/json/misc/00c36.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/00c36.json/default/TopLevel.js
index 8615a96..381e8e5 100644
--- a/base/flow/test/inputs/json/misc/00c36.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/00c36.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export type PurpleTopLevel = {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -32,7 +34,7 @@ export type Value =
       "United States"
     | "GDP (current US$)";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     page:     number;
     pages:    number;
     per_page: string;
@@ -41,12 +43,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -203,7 +205,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -214,7 +216,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/010b1.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/010b1.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/010b1.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/010b1.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/050b0.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/050b0.json/default/TopLevel.js
index 5859c8d..5896aed 100644
--- a/base/flow/test/inputs/json/misc/050b0.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/050b0.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -69,12 +71,12 @@ export type Title =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -231,7 +233,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/06bee.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/06bee.json/default/TopLevel.js
index 11aefeb..fe571e3 100644
--- a/base/flow/test/inputs/json/misc/06bee.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/06bee.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -57,12 +59,12 @@ export type Title =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -219,7 +221,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/07c75.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/07c75.json/default/TopLevel.js
index bb5ab41..8a43ba1 100644
--- a/base/flow/test/inputs/json/misc/07c75.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/07c75.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      string[];
@@ -38,12 +40,12 @@ export type Text = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -200,7 +202,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a("") },
diff --git a/base/flow/test/inputs/json/misc/0a91a.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/0a91a.json/default/TopLevel.js
index 069ddd9..ff9de36 100644
--- a/base/flow/test/inputs/json/misc/0a91a.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/0a91a.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     actor:      Actor;
     created_at: Date;
     id:         string;
@@ -233,12 +235,12 @@ export type Type =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -395,7 +397,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "actor", js: "actor", typ: r("Actor") },
         { json: "created_at", js: "created_at", typ: Date },
         { json: "id", js: "id", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/10be4.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/10be4.json/default/TopLevel.js
index d078882..9687b77 100644
--- a/base/flow/test/inputs/json/misc/10be4.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/10be4.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -80,12 +82,12 @@ export type Title =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -242,7 +244,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/13d8d.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/13d8d.json/default/TopLevel.js
index 5806fb5..d5ca639 100644
--- a/base/flow/test/inputs/json/misc/13d8d.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/13d8d.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     category:         string;
     context:          string;
     id:               number;
@@ -39,12 +41,12 @@ export type OutcomeStatus = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -201,7 +203,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "category", js: "category", typ: "" },
         { json: "context", js: "context", typ: "" },
         { json: "id", js: "id", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/1a7f5.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/1a7f5.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/1a7f5.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/1a7f5.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/2df80.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/2df80.json/default/TopLevel.js
index db21701..4a7a449 100644
--- a/base/flow/test/inputs/json/misc/2df80.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/2df80.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export type PurpleTopLevel = {
     adminregion: Adminregion;
     capitalCity: string;
     id:          string;
@@ -77,7 +79,7 @@ export type Value =
     | "East Asia & Pacific"
     | "North America";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     page:     number;
     pages:    number;
     per_page: string;
@@ -86,12 +88,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -248,7 +250,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "adminregion", js: "adminregion", typ: r("Adminregion") },
         { json: "capitalCity", js: "capitalCity", typ: "" },
         { json: "id", js: "id", typ: "" },
@@ -264,7 +266,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/32d5c.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/32d5c.json/default/TopLevel.js
index 814db0c..9284fff 100644
--- a/base/flow/test/inputs/json/misc/32d5c.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/32d5c.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     BirthDate:            Date | null;
     BirthDateIsProtected: boolean;
     GenderTypeID:         number;
@@ -22,12 +24,12 @@ export type TopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "BirthDate", js: "BirthDate", typ: u(Date, null) },
         { json: "BirthDateIsProtected", js: "BirthDateIsProtected", typ: true },
         { json: "GenderTypeID", js: "GenderTypeID", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/3536b.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/3536b.json/default/TopLevel.js
index b75e569..5df9a86 100644
--- a/base/flow/test/inputs/json/misc/3536b.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/3536b.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -48,12 +50,12 @@ export type Text = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -210,7 +212,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/43970.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/43970.json/default/TopLevel.js
index 529ab8a..6efce4c 100644
--- a/base/flow/test/inputs/json/misc/43970.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/43970.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     ID:    number;
     Name:  string;
     Notes: string;
@@ -17,12 +19,12 @@ export type TopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "ID", js: "ID", typ: 0 },
         { json: "Name", js: "Name", typ: "" },
         { json: "Notes", js: "Notes", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/570ec.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/570ec.json/default/TopLevel.js
index ebe61d0..ebb25ac 100644
--- a/base/flow/test/inputs/json/misc/570ec.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/570ec.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      string[];
@@ -48,12 +50,12 @@ export type Text = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -210,7 +212,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a("") },
diff --git a/base/flow/test/inputs/json/misc/5eae5.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/5eae5.json/default/TopLevel.js
index 65d5b0e..395b063 100644
--- a/base/flow/test/inputs/json/misc/5eae5.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/5eae5.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     Date:    Date;
     ID:      number;
     Sponsor: string;
@@ -18,12 +20,12 @@ export type TopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -180,7 +182,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "Date", js: "Date", typ: Date },
         { json: "ID", js: "ID", typ: 0 },
         { json: "Sponsor", js: "Sponsor", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/66121.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/66121.json/default/TopLevel.js
index d5c707b..6d0f9ff 100644
--- a/base/flow/test/inputs/json/misc/66121.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/66121.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -57,12 +59,12 @@ export type Title =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -219,7 +221,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/6eb00.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/6eb00.json/default/TopLevel.js
index cb3c6f1..15ecaba 100644
--- a/base/flow/test/inputs/json/misc/6eb00.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/6eb00.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     DirectorateID: number;
     Id:            number;
     Name:          string;
@@ -17,12 +19,12 @@ export type TopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "DirectorateID", js: "DirectorateID", typ: 0 },
         { json: "Id", js: "Id", typ: 0 },
         { json: "Name", js: "Name", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/77392.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/77392.json/default/TopLevel.js
index fd100eb..150a4fb 100644
--- a/base/flow/test/inputs/json/misc/77392.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/77392.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     designation:    string;
     discovery_date: Date;
     h_mag?:         string;
@@ -40,12 +42,12 @@ export type Pha =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -202,7 +204,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "designation", js: "designation", typ: "" },
         { json: "discovery_date", js: "discovery_date", typ: Date },
         { json: "h_mag", js: "h_mag", typ: u(undefined, "") },
diff --git a/base/flow/test/inputs/json/misc/7f568.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/7f568.json/default/TopLevel.js
index 9c1f1ed..9cdba87 100644
--- a/base/flow/test/inputs/json/misc/7f568.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/7f568.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     comments:     number;
     comments_url: string;
     commits_url:  string;
@@ -44,12 +46,12 @@ export type Type =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -206,7 +208,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "comments", js: "comments", typ: 0 },
         { json: "comments_url", js: "comments_url", typ: "" },
         { json: "commits_url", js: "commits_url", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/7fbfb.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/7fbfb.json/default/TopLevel.js
index 17f84e8..7e60648 100644
--- a/base/flow/test/inputs/json/misc/7fbfb.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/7fbfb.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export type PurpleTopLevel = {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -32,7 +34,7 @@ export type Value =
       "China"
     | "GDP (current US$)";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     page:     number;
     pages:    number;
     per_page: string;
@@ -41,12 +43,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -203,7 +205,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -214,7 +216,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/9847b.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/9847b.json/default/TopLevel.js
index 7752996..bf75f0a 100644
--- a/base/flow/test/inputs/json/misc/9847b.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/9847b.json/default/TopLevel.js
@@ -9,19 +9,21 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:   string;
     name: string;
 };
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -178,7 +180,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "name", js: "name", typ: "" },
     ], false),
diff --git a/base/flow/test/inputs/json/misc/996bd.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/996bd.json/default/TopLevel.js
index 218f65a..84e729f 100644
--- a/base/flow/test/inputs/json/misc/996bd.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/996bd.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -57,12 +59,12 @@ export type Title =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -219,7 +221,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/9a503.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/9a503.json/default/TopLevel.js
index 1d57638..6b99462 100644
--- a/base/flow/test/inputs/json/misc/9a503.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/9a503.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -43,12 +45,12 @@ export type Text = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -205,7 +207,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/9eed5.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/9eed5.json/default/TopLevel.js
index a8d4337..323b0dd 100644
--- a/base/flow/test/inputs/json/misc/9eed5.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/9eed5.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -42,12 +44,12 @@ export type Text = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -204,7 +206,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/a45b0.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/a45b0.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/a45b0.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/a45b0.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/ab0d1.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/ab0d1.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/ab0d1.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/ab0d1.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/ad8be.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/ad8be.json/default/TopLevel.js
index d078882..9687b77 100644
--- a/base/flow/test/inputs/json/misc/ad8be.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/ad8be.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -80,12 +82,12 @@ export type Title =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -242,7 +244,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/flow/test/inputs/json/misc/b4865.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/b4865.json/default/TopLevel.js
index c5755ca..7db4ec9 100644
--- a/base/flow/test/inputs/json/misc/b4865.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/b4865.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     ":@computed_region_cbhk_fwbd"?: string;
     ":@computed_region_nnqa_25f4"?: string;
     fall:                           Fall;
@@ -41,12 +43,12 @@ export type Nametype =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -203,7 +205,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: ":@computed_region_cbhk_fwbd", js: ":@computed_region_cbhk_fwbd", typ: u(undefined, "") },
         { json: ":@computed_region_nnqa_25f4", js: ":@computed_region_nnqa_25f4", typ: u(undefined, "") },
         { json: "fall", js: "fall", typ: r("Fall") },
diff --git a/base/flow/test/inputs/json/misc/c8c7e.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/c8c7e.json/default/TopLevel.js
index d85a228..640243c 100644
--- a/base/flow/test/inputs/json/misc/c8c7e.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/c8c7e.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export type PurpleTopLevel = {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -32,7 +34,7 @@ export type Value =
       "India"
     | "GDP (current US$)";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     page:     number;
     pages:    number;
     per_page: string;
@@ -41,12 +43,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -203,7 +205,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -214,7 +216,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/cda6c.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/cda6c.json/default/TopLevel.js
index 127ef47..bad1888 100644
--- a/base/flow/test/inputs/json/misc/cda6c.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/cda6c.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export type PurpleTopLevel = {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -32,7 +34,7 @@ export type Value =
       "China"
     | "Population, total";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     page:     number;
     pages:    number;
     per_page: string;
@@ -41,12 +43,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -203,7 +205,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -214,7 +216,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/e2a58.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/e2a58.json/default/TopLevel.js
index 5cd50d1..42f6577 100644
--- a/base/flow/test/inputs/json/misc/e2a58.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/e2a58.json/default/TopLevel.js
@@ -9,19 +9,21 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     date:              string;
     "stop-and-search": string[];
 };
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -178,7 +180,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "date", js: "date", typ: "" },
         { json: "stop-and-search", js: "stop-and-search", typ: a("") },
     ], false),
diff --git a/base/flow/test/inputs/json/misc/e53b5.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/e53b5.json/default/TopLevel.js
index 9924203..4cc5e86 100644
--- a/base/flow/test/inputs/json/misc/e53b5.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/e53b5.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export type PurpleTopLevel = {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -32,7 +34,7 @@ export type Value =
       "India"
     | "Population, total";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     page:     number;
     pages:    number;
     per_page: string;
@@ -41,12 +43,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -203,7 +205,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -214,7 +216,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/flow/test/inputs/json/misc/e8a0b.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/e8a0b.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/e8a0b.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/e8a0b.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/e8b04.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/e8b04.json/default/TopLevel.js
index 9f7576a..beec6a4 100644
--- a/base/flow/test/inputs/json/misc/e8b04.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/e8b04.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     averageRating:            number;
     category?:                string;
     createdAt:                number;
@@ -283,12 +285,12 @@ export type ViewType =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -445,7 +447,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "averageRating", js: "averageRating", typ: 0 },
         { json: "category", js: "category", typ: u(undefined, "") },
         { json: "createdAt", js: "createdAt", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/f3139.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/f3139.json/default/TopLevel.js
index 7752996..bf75f0a 100644
--- a/base/flow/test/inputs/json/misc/f3139.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/f3139.json/default/TopLevel.js
@@ -9,19 +9,21 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     id:   string;
     name: string;
 };
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -178,7 +180,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "name", js: "name", typ: "" },
     ], false),
diff --git a/base/flow/test/inputs/json/misc/f3edf.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/f3edf.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/f3edf.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/f3edf.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/misc/f466a.json/default/TopLevel.js b/head/flow/test/inputs/json/misc/f466a.json/default/TopLevel.js
index 57f2b0a..b0694cc 100644
--- a/base/flow/test/inputs/json/misc/f466a.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/misc/f466a.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     age:     number;
     country: Country;
     females: number;
@@ -23,12 +25,12 @@ export type Country =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -185,7 +187,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/flow/test/inputs/json/priority/bug863.json/default/TopLevel.js b/head/flow/test/inputs/json/priority/bug863.json/default/TopLevel.js
index 3ce98e3..a0aa184 100644
--- a/base/flow/test/inputs/json/priority/bug863.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/priority/bug863.json/default/TopLevel.js
@@ -9,9 +9,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel | string;
+export type TopLevel = TopLevelUnion[];
 
-export type TopLevelElement = {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel | string;
+
+export type PurpleTopLevel = {
     ALIENLEVEL:          number;
     BREED:               Breed;
     CHAR_DIMENSION:      number;
@@ -59,7 +61,7 @@ export type Sex =
     | "Male"
     | "Female";
 
-export type PurpleTopLevel = {
+export type FluffyTopLevel = {
     ADVENTURERCOUNT: number;
     AGENTCOUNT:      number;
     ATROXCOUNT:      number;
@@ -99,12 +101,12 @@ export type PurpleTopLevel = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"), "")));
+function toTopLevel(json: string): TopLevelUnion[] {
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"), "")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel"), ""))), null, 2);
+function topLevelToJson(value: TopLevelUnion[]): string {
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"), ""))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -261,7 +263,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "ALIENLEVEL", js: "ALIENLEVEL", typ: 0 },
         { json: "BREED", js: "BREED", typ: r("Breed") },
         { json: "CHAR_DIMENSION", js: "CHAR_DIMENSION", typ: 0 },
@@ -280,7 +282,7 @@ const typeMap: any = {
         { json: "RANK_TITLE", js: "RANK_TITLE", typ: r("RankTitle") },
         { json: "SEX", js: "SEX", typ: r("Sex") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "ADVENTURERCOUNT", js: "ADVENTURERCOUNT", typ: 0 },
         { json: "AGENTCOUNT", js: "AGENTCOUNT", typ: 0 },
         { json: "ATROXCOUNT", js: "ATROXCOUNT", typ: 0 },
diff --git a/base/flow/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js b/head/flow/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js
index 2265201..bf58b59 100644
--- a/base/flow/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js
@@ -9,18 +9,20 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     key: string;
 };
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -177,7 +179,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "key", js: "key", typ: "" },
     ], false),
 };
diff --git a/base/flow/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.js b/head/flow/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.js
index 5506863..40e06d9 100644
--- a/base/flow/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.js
@@ -9,6 +9,8 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
+export type TopLevel = number[];
+
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json: string): number[] {
diff --git a/base/flow/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js b/head/flow/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js
index 573e07e..65d0513 100644
--- a/base/flow/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     category: Category;
 };
 
@@ -19,12 +21,12 @@ export type Category =
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -181,7 +183,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "category", js: "category", typ: r("Category") },
     ], false),
     "Category": [
diff --git a/base/flow/test/inputs/json/priority/optional-union.json/default/TopLevel.js b/head/flow/test/inputs/json/priority/optional-union.json/default/TopLevel.js
index bac13b1..55b34bf 100644
--- a/base/flow/test/inputs/json/priority/optional-union.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/priority/optional-union.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     a?: A;
 };
 
@@ -17,12 +19,12 @@ export type A = number | string;
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "a", js: "a", typ: u(undefined, u(0, "")) },
     ], false),
 };
diff --git a/base/flow/test/inputs/json/samples/github-events.json/default/TopLevel.js b/head/flow/test/inputs/json/samples/github-events.json/default/TopLevel.js
index 398cd8b..9ec1044 100644
--- a/base/flow/test/inputs/json/samples/github-events.json/default/TopLevel.js
+++ b/head/flow/test/inputs/json/samples/github-events.json/default/TopLevel.js
@@ -9,7 +9,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = {
+export type TopLevel = TopLevelElement[];
+
+export type TopLevelElement = {
     actor:      Actor;
     created_at: Date;
     id:         string;
@@ -301,12 +303,12 @@ export type TopLevelRepo = {
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
-function toTopLevel(json: string): TopLevel[] {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+function toTopLevel(json: string): TopLevelElement[] {
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
-function topLevelToJson(value: TopLevel[]): string {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+function topLevelToJson(value: TopLevelElement[]): string {
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ: any, val: any, key: any, parent: any = '') {
@@ -463,7 +465,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "actor", js: "actor", typ: r("Actor") },
         { json: "created_at", js: "created_at", typ: Date },
         { json: "id", js: "id", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/00c36.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/00c36.json/default/TopLevel.js
index 591f9f3..2738e43 100644
--- a/base/javascript/test/inputs/json/misc/00c36.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/00c36.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -182,7 +182,7 @@ const typeMap = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/010b1.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/010b1.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/010b1.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/010b1.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/050b0.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/050b0.json/default/TopLevel.js
index 35b4543..63955bb 100644
--- a/base/javascript/test/inputs/json/misc/050b0.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/050b0.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/06bee.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/06bee.json/default/TopLevel.js
index 43166ea..c3f8947 100644
--- a/base/javascript/test/inputs/json/misc/06bee.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/06bee.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/07c75.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/07c75.json/default/TopLevel.js
index fecf6bd..74073c3 100644
--- a/base/javascript/test/inputs/json/misc/07c75.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/07c75.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a("") },
diff --git a/base/javascript/test/inputs/json/misc/0a91a.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/0a91a.json/default/TopLevel.js
index c8e9f63..7101534 100644
--- a/base/javascript/test/inputs/json/misc/0a91a.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/0a91a.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "actor", js: "actor", typ: r("Actor") },
         { json: "created_at", js: "created_at", typ: Date },
         { json: "id", js: "id", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/10be4.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/10be4.json/default/TopLevel.js
index 4014c2a..ba53845 100644
--- a/base/javascript/test/inputs/json/misc/10be4.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/10be4.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/13d8d.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/13d8d.json/default/TopLevel.js
index b97d5d8..1631142 100644
--- a/base/javascript/test/inputs/json/misc/13d8d.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/13d8d.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "category", js: "category", typ: "" },
         { json: "context", js: "context", typ: "" },
         { json: "id", js: "id", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/1a7f5.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/1a7f5.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/1a7f5.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/1a7f5.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/2df80.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/2df80.json/default/TopLevel.js
index a183449..3cfa974 100644
--- a/base/javascript/test/inputs/json/misc/2df80.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/2df80.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "adminregion", js: "adminregion", typ: r("Adminregion") },
         { json: "capitalCity", js: "capitalCity", typ: "" },
         { json: "id", js: "id", typ: "" },
@@ -187,7 +187,7 @@ const typeMap = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/32d5c.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/32d5c.json/default/TopLevel.js
index 00c2090..38bd2b0 100644
--- a/base/javascript/test/inputs/json/misc/32d5c.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/32d5c.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "BirthDate", js: "BirthDate", typ: u(Date, null) },
         { json: "BirthDateIsProtected", js: "BirthDateIsProtected", typ: true },
         { json: "GenderTypeID", js: "GenderTypeID", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/3536b.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/3536b.json/default/TopLevel.js
index 5d9d8ed..21762eb 100644
--- a/base/javascript/test/inputs/json/misc/3536b.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/3536b.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/43970.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/43970.json/default/TopLevel.js
index 54d9939..53f26f7 100644
--- a/base/javascript/test/inputs/json/misc/43970.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/43970.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "ID", js: "ID", typ: 0 },
         { json: "Name", js: "Name", typ: "" },
         { json: "Notes", js: "Notes", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/570ec.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/570ec.json/default/TopLevel.js
index fa15027..98dc7ae 100644
--- a/base/javascript/test/inputs/json/misc/570ec.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/570ec.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a("") },
diff --git a/base/javascript/test/inputs/json/misc/5eae5.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/5eae5.json/default/TopLevel.js
index baf3d97..32ab451 100644
--- a/base/javascript/test/inputs/json/misc/5eae5.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/5eae5.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "Date", js: "Date", typ: Date },
         { json: "ID", js: "ID", typ: 0 },
         { json: "Sponsor", js: "Sponsor", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/66121.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/66121.json/default/TopLevel.js
index 369ad4b..62b4005 100644
--- a/base/javascript/test/inputs/json/misc/66121.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/66121.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/6eb00.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/6eb00.json/default/TopLevel.js
index a701c0d..262d781 100644
--- a/base/javascript/test/inputs/json/misc/6eb00.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/6eb00.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "DirectorateID", js: "DirectorateID", typ: 0 },
         { json: "Id", js: "Id", typ: 0 },
         { json: "Name", js: "Name", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/77392.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/77392.json/default/TopLevel.js
index bda7376..902dbed 100644
--- a/base/javascript/test/inputs/json/misc/77392.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/77392.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "designation", js: "designation", typ: "" },
         { json: "discovery_date", js: "discovery_date", typ: Date },
         { json: "h_mag", js: "h_mag", typ: u(undefined, "") },
diff --git a/base/javascript/test/inputs/json/misc/7f568.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/7f568.json/default/TopLevel.js
index f79573e..f2402bb 100644
--- a/base/javascript/test/inputs/json/misc/7f568.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/7f568.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "comments", js: "comments", typ: 0 },
         { json: "comments_url", js: "comments_url", typ: "" },
         { json: "commits_url", js: "commits_url", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/7fbfb.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/7fbfb.json/default/TopLevel.js
index 3c8973b..a5eb1eb 100644
--- a/base/javascript/test/inputs/json/misc/7fbfb.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/7fbfb.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -182,7 +182,7 @@ const typeMap = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/9847b.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/9847b.json/default/TopLevel.js
index d256f99..7b74475 100644
--- a/base/javascript/test/inputs/json/misc/9847b.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/9847b.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "name", js: "name", typ: "" },
     ], false),
diff --git a/base/javascript/test/inputs/json/misc/996bd.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/996bd.json/default/TopLevel.js
index a10a4d9..039e355 100644
--- a/base/javascript/test/inputs/json/misc/996bd.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/996bd.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/9a503.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/9a503.json/default/TopLevel.js
index b998c43..c329c2b 100644
--- a/base/javascript/test/inputs/json/misc/9a503.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/9a503.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/9eed5.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/9eed5.json/default/TopLevel.js
index 1f30fca..4a1fea7 100644
--- a/base/javascript/test/inputs/json/misc/9eed5.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/9eed5.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/a45b0.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/a45b0.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/a45b0.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/a45b0.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/ab0d1.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/ab0d1.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/ab0d1.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/ab0d1.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/ad8be.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/ad8be.json/default/TopLevel.js
index 4014c2a..ba53845 100644
--- a/base/javascript/test/inputs/json/misc/ad8be.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/ad8be.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/javascript/test/inputs/json/misc/b4865.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/b4865.json/default/TopLevel.js
index 1e927ae..261fb28 100644
--- a/base/javascript/test/inputs/json/misc/b4865.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/b4865.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: ":@computed_region_cbhk_fwbd", js: ":@computed_region_cbhk_fwbd", typ: u(undefined, "") },
         { json: ":@computed_region_nnqa_25f4", js: ":@computed_region_nnqa_25f4", typ: u(undefined, "") },
         { json: "fall", js: "fall", typ: r("Fall") },
diff --git a/base/javascript/test/inputs/json/misc/c8c7e.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/c8c7e.json/default/TopLevel.js
index f678c8f..e8cf5ac 100644
--- a/base/javascript/test/inputs/json/misc/c8c7e.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/c8c7e.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -182,7 +182,7 @@ const typeMap = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/cda6c.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/cda6c.json/default/TopLevel.js
index 82d8343..33d9030 100644
--- a/base/javascript/test/inputs/json/misc/cda6c.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/cda6c.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -182,7 +182,7 @@ const typeMap = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/e2a58.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/e2a58.json/default/TopLevel.js
index 48565ea..8be9dd5 100644
--- a/base/javascript/test/inputs/json/misc/e2a58.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/e2a58.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "date", js: "date", typ: "" },
         { json: "stop-and-search", js: "stop-and-search", typ: a("") },
     ], false),
diff --git a/base/javascript/test/inputs/json/misc/e53b5.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/e53b5.json/default/TopLevel.js
index 98d4025..7e25ff5 100644
--- a/base/javascript/test/inputs/json/misc/e53b5.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/e53b5.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -182,7 +182,7 @@ const typeMap = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/javascript/test/inputs/json/misc/e8a0b.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/e8a0b.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/e8a0b.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/e8a0b.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/e8b04.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/e8b04.json/default/TopLevel.js
index 05443e2..e9a77d7 100644
--- a/base/javascript/test/inputs/json/misc/e8b04.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/e8b04.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "averageRating", js: "averageRating", typ: 0 },
         { json: "category", js: "category", typ: u(undefined, "") },
         { json: "createdAt", js: "createdAt", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/f3139.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/f3139.json/default/TopLevel.js
index d256f99..7b74475 100644
--- a/base/javascript/test/inputs/json/misc/f3139.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/f3139.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "name", js: "name", typ: "" },
     ], false),
diff --git a/base/javascript/test/inputs/json/misc/f3edf.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/f3edf.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/f3edf.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/f3edf.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/misc/f466a.json/default/TopLevel.js b/head/javascript/test/inputs/json/misc/f466a.json/default/TopLevel.js
index f6b873f..d040942 100644
--- a/base/javascript/test/inputs/json/misc/f466a.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/misc/f466a.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/javascript/test/inputs/json/priority/bug863.json/default/TopLevel.js b/head/javascript/test/inputs/json/priority/bug863.json/default/TopLevel.js
index b22fcc1..7451ddb 100644
--- a/base/javascript/test/inputs/json/priority/bug863.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/priority/bug863.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"), "")));
+    return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"), "")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel"), ""))), null, 2);
+    return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"), ""))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "ALIENLEVEL", js: "ALIENLEVEL", typ: 0 },
         { json: "BREED", js: "BREED", typ: r("Breed") },
         { json: "CHAR_DIMENSION", js: "CHAR_DIMENSION", typ: 0 },
@@ -190,7 +190,7 @@ const typeMap = {
         { json: "RANK_TITLE", js: "RANK_TITLE", typ: r("RankTitle") },
         { json: "SEX", js: "SEX", typ: r("Sex") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "ADVENTURERCOUNT", js: "ADVENTURERCOUNT", typ: 0 },
         { json: "AGENTCOUNT", js: "AGENTCOUNT", typ: 0 },
         { json: "ATROXCOUNT", js: "ATROXCOUNT", typ: 0 },
diff --git a/base/javascript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js b/head/javascript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js
index 4e15ada..9179837 100644
--- a/base/javascript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "key", js: "key", typ: "" },
     ], false),
 };
diff --git a/base/javascript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js b/head/javascript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js
index 6fe75cc..55b4e00 100644
--- a/base/javascript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "category", js: "category", typ: r("Category") },
     ], false),
     "Category": [
diff --git a/base/javascript/test/inputs/json/priority/optional-union.json/default/TopLevel.js b/head/javascript/test/inputs/json/priority/optional-union.json/default/TopLevel.js
index 7b8b5f5..26a6d6e 100644
--- a/base/javascript/test/inputs/json/priority/optional-union.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/priority/optional-union.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "a", js: "a", typ: u(undefined, u(0, "")) },
     ], false),
 };
diff --git a/base/javascript/test/inputs/json/samples/github-events.json/default/TopLevel.js b/head/javascript/test/inputs/json/samples/github-events.json/default/TopLevel.js
index 077bf20..e1c216d 100644
--- a/base/javascript/test/inputs/json/samples/github-events.json/default/TopLevel.js
+++ b/head/javascript/test/inputs/json/samples/github-events.json/default/TopLevel.js
@@ -10,11 +10,11 @@
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 function toTopLevel(json) {
-    return cast(JSON.parse(json), a(r("TopLevel")));
+    return cast(JSON.parse(json), a(r("TopLevelElement")));
 }
 
 function topLevelToJson(value) {
-    return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
 }
 
 function invalidValue(typ, val, key, parent = '') {
@@ -171,7 +171,7 @@ function r(name) {
 }
 
 const typeMap = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "actor", js: "actor", typ: r("Actor") },
         { json: "created_at", js: "created_at", typ: Date },
         { json: "id", js: "id", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/00c36.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/00c36.json/default/TopLevel.ts
index ec3ba2b..5a50415 100644
--- a/base/typescript/test/inputs/json/misc/00c36.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/00c36.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export interface PurpleTopLevel {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -26,7 +28,7 @@ export type ID = "US" | "NY.GDP.MKTP.CD";
 
 export type Value = "United States" | "GDP (current US$)";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     page:     number;
     pages:    number;
     per_page: string;
@@ -36,12 +38,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
     }
 }
 
@@ -199,7 +201,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -210,7 +212,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/010b1.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/010b1.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/010b1.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/010b1.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/050b0.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/050b0.json/default/TopLevel.ts
index 3a81c70..b27570a 100644
--- a/base/typescript/test/inputs/json/misc/050b0.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/050b0.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -52,12 +54,12 @@ export type Title = "HTML" | "Plain Text";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -215,7 +217,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/06bee.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/06bee.json/default/TopLevel.ts
index f6d8b99..2abc823 100644
--- a/base/typescript/test/inputs/json/misc/06bee.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/06bee.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -47,12 +49,12 @@ export type Title = "HTML";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -210,7 +212,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/07c75.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/07c75.json/default/TopLevel.ts
index 3fca6b7..852f736 100644
--- a/base/typescript/test/inputs/json/misc/07c75.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/07c75.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      string[];
@@ -37,12 +39,12 @@ export interface Text {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -200,7 +202,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a("") },
diff --git a/base/typescript/test/inputs/json/misc/0a91a.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/0a91a.json/default/TopLevel.ts
index fcc76df..5959f35 100644
--- a/base/typescript/test/inputs/json/misc/0a91a.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/0a91a.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     actor:      Actor;
     created_at: Date;
     id:         string;
@@ -227,12 +229,12 @@ export type Type = "PushEvent" | "CreateEvent" | "WatchEvent" | "PullRequestEven
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -390,7 +392,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "actor", js: "actor", typ: r("Actor") },
         { json: "created_at", js: "created_at", typ: Date },
         { json: "id", js: "id", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/10be4.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/10be4.json/default/TopLevel.ts
index 72874a8..b0bc52b 100644
--- a/base/typescript/test/inputs/json/misc/10be4.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/10be4.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -52,12 +54,12 @@ export type Title = "HTML" | "Plain Text" | "PDF";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -215,7 +217,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/13d8d.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/13d8d.json/default/TopLevel.ts
index 63d7b44..5043b9c 100644
--- a/base/typescript/test/inputs/json/misc/13d8d.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/13d8d.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     category:         string;
     context:          string;
     id:               number;
@@ -38,12 +40,12 @@ export interface OutcomeStatus {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -201,7 +203,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "category", js: "category", typ: "" },
         { json: "context", js: "context", typ: "" },
         { json: "id", js: "id", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/1a7f5.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/1a7f5.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/1a7f5.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/1a7f5.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/2df80.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/2df80.json/default/TopLevel.ts
index 3579b5f..c047b3d 100644
--- a/base/typescript/test/inputs/json/misc/2df80.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/2df80.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export interface PurpleTopLevel {
     adminregion: Adminregion;
     capitalCity: string;
     id:          string;
@@ -31,7 +33,7 @@ export type ID = "" | "SAS" | "SSA" | "ECA" | "LAC" | "EAP" | "MNA" | "HIC" | "L
 
 export type Value = "" | "South Asia" | "Sub-Saharan Africa (excluding high income)" | "Europe & Central Asia (excluding high income)" | "Latin America & Caribbean (excluding high income)" | "East Asia & Pacific (excluding high income)" | "Middle East & North Africa (excluding high income)" | "High income" | "Low income" | "Aggregates" | "Lower middle income" | "Upper middle income" | "Not classified" | "IDA" | "IBRD" | "Blend" | "Latin America & Caribbean " | "Sub-Saharan Africa " | "Europe & Central Asia" | "Middle East & North Africa" | "East Asia & Pacific" | "North America";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     page:     number;
     pages:    number;
     per_page: string;
@@ -41,12 +43,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
     }
 }
 
@@ -204,7 +206,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "adminregion", js: "adminregion", typ: r("Adminregion") },
         { json: "capitalCity", js: "capitalCity", typ: "" },
         { json: "id", js: "id", typ: "" },
@@ -220,7 +222,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/32d5c.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/32d5c.json/default/TopLevel.ts
index 46f2be2..330667c 100644
--- a/base/typescript/test/inputs/json/misc/32d5c.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/32d5c.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     BirthDate:            Date | null;
     BirthDateIsProtected: boolean;
     GenderTypeID:         number;
@@ -21,12 +23,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "BirthDate", js: "BirthDate", typ: u(Date, null) },
         { json: "BirthDateIsProtected", js: "BirthDateIsProtected", typ: true },
         { json: "GenderTypeID", js: "GenderTypeID", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/3536b.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/3536b.json/default/TopLevel.ts
index 5572056..cde7121 100644
--- a/base/typescript/test/inputs/json/misc/3536b.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/3536b.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -41,12 +43,12 @@ export interface Text {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -204,7 +206,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/43970.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/43970.json/default/TopLevel.ts
index 045cf4c..e265a84 100644
--- a/base/typescript/test/inputs/json/misc/43970.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/43970.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     ID:    number;
     Name:  string;
     Notes: string;
@@ -16,12 +18,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "ID", js: "ID", typ: 0 },
         { json: "Name", js: "Name", typ: "" },
         { json: "Notes", js: "Notes", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/570ec.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/570ec.json/default/TopLevel.ts
index 8f9efcb..4d0ddaa 100644
--- a/base/typescript/test/inputs/json/misc/570ec.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/570ec.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      string[];
@@ -44,12 +46,12 @@ export interface Text {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -207,7 +209,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a("") },
diff --git a/base/typescript/test/inputs/json/misc/5eae5.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/5eae5.json/default/TopLevel.ts
index 6c1cb4f..e86ae41 100644
--- a/base/typescript/test/inputs/json/misc/5eae5.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/5eae5.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     Date:    Date;
     ID:      number;
     Sponsor: string;
@@ -17,12 +19,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -180,7 +182,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "Date", js: "Date", typ: Date },
         { json: "ID", js: "ID", typ: 0 },
         { json: "Sponsor", js: "Sponsor", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/66121.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/66121.json/default/TopLevel.ts
index f3d3c7a..ab15507 100644
--- a/base/typescript/test/inputs/json/misc/66121.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/66121.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -47,12 +49,12 @@ export type Title = "HTML";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -210,7 +212,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/6eb00.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/6eb00.json/default/TopLevel.ts
index 5c6df64..491fe30 100644
--- a/base/typescript/test/inputs/json/misc/6eb00.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/6eb00.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     DirectorateID: number;
     Id:            number;
     Name:          string;
@@ -16,12 +18,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "DirectorateID", js: "DirectorateID", typ: 0 },
         { json: "Id", js: "Id", typ: 0 },
         { json: "Name", js: "Name", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/77392.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/77392.json/default/TopLevel.ts
index bd22f57..15708ae 100644
--- a/base/typescript/test/inputs/json/misc/77392.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/77392.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     designation:    string;
     discovery_date: Date;
     h_mag?:         string;
@@ -27,12 +29,12 @@ export type Pha = "Y" | "N" | "n/a";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -190,7 +192,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "designation", js: "designation", typ: "" },
         { json: "discovery_date", js: "discovery_date", typ: Date },
         { json: "h_mag", js: "h_mag", typ: u(undefined, "") },
diff --git a/base/typescript/test/inputs/json/misc/7f568.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/7f568.json/default/TopLevel.ts
index 9811c74..36397d3 100644
--- a/base/typescript/test/inputs/json/misc/7f568.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/7f568.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     comments:     number;
     comments_url: string;
     commits_url:  string;
@@ -41,12 +43,12 @@ export type Type = "text/plain";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -204,7 +206,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "comments", js: "comments", typ: 0 },
         { json: "comments_url", js: "comments_url", typ: "" },
         { json: "commits_url", js: "commits_url", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/7fbfb.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/7fbfb.json/default/TopLevel.ts
index 98ac0ff..5ae6910 100644
--- a/base/typescript/test/inputs/json/misc/7fbfb.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/7fbfb.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export interface PurpleTopLevel {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -26,7 +28,7 @@ export type ID = "CN" | "NY.GDP.MKTP.CD";
 
 export type Value = "China" | "GDP (current US$)";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     page:     number;
     pages:    number;
     per_page: string;
@@ -36,12 +38,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
     }
 }
 
@@ -199,7 +201,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -210,7 +212,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/9847b.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/9847b.json/default/TopLevel.ts
index 9aee0ae..7d4ac1e 100644
--- a/base/typescript/test/inputs/json/misc/9847b.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/9847b.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:   string;
     name: string;
 }
@@ -15,12 +17,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -178,7 +180,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "name", js: "name", typ: "" },
     ], false),
diff --git a/base/typescript/test/inputs/json/misc/996bd.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/996bd.json/default/TopLevel.ts
index 45af1cc..5c3ccb4 100644
--- a/base/typescript/test/inputs/json/misc/996bd.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/996bd.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -45,12 +47,12 @@ export type Title = "Plain Text" | "HTML";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -208,7 +210,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/9a503.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/9a503.json/default/TopLevel.ts
index c0ee0ae..3aaa5ae 100644
--- a/base/typescript/test/inputs/json/misc/9a503.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/9a503.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -39,12 +41,12 @@ export interface Text {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -202,7 +204,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/9eed5.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/9eed5.json/default/TopLevel.ts
index 18cf5a2..cecd9d2 100644
--- a/base/typescript/test/inputs/json/misc/9eed5.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/9eed5.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -39,12 +41,12 @@ export interface Text {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -202,7 +204,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/a45b0.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/a45b0.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/a45b0.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/a45b0.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/ab0d1.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/ab0d1.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/ab0d1.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/ab0d1.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/ad8be.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/ad8be.json/default/TopLevel.ts
index 72874a8..b0bc52b 100644
--- a/base/typescript/test/inputs/json/misc/ad8be.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/ad8be.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:            string;
     identifiers:   Identifier[];
     keywords:      Keyword[];
@@ -52,12 +54,12 @@ export type Title = "HTML" | "Plain Text" | "PDF";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -215,7 +217,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "identifiers", js: "identifiers", typ: a(r("Identifier")) },
         { json: "keywords", js: "keywords", typ: a(r("Keyword")) },
diff --git a/base/typescript/test/inputs/json/misc/b4865.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/b4865.json/default/TopLevel.ts
index 29944d2..0f865c9 100644
--- a/base/typescript/test/inputs/json/misc/b4865.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/b4865.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     ":@computed_region_cbhk_fwbd"?: string;
     ":@computed_region_nnqa_25f4"?: string;
     fall:                           Fall;
@@ -36,12 +38,12 @@ export type Nametype = "Valid";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -199,7 +201,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: ":@computed_region_cbhk_fwbd", js: ":@computed_region_cbhk_fwbd", typ: u(undefined, "") },
         { json: ":@computed_region_nnqa_25f4", js: ":@computed_region_nnqa_25f4", typ: u(undefined, "") },
         { json: "fall", js: "fall", typ: r("Fall") },
diff --git a/base/typescript/test/inputs/json/misc/c8c7e.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/c8c7e.json/default/TopLevel.ts
index ebf76ed..4699457 100644
--- a/base/typescript/test/inputs/json/misc/c8c7e.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/c8c7e.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export interface PurpleTopLevel {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -26,7 +28,7 @@ export type ID = "IN" | "NY.GDP.MKTP.CD";
 
 export type Value = "India" | "GDP (current US$)";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     page:     number;
     pages:    number;
     per_page: string;
@@ -36,12 +38,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
     }
 }
 
@@ -199,7 +201,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -210,7 +212,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/cda6c.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/cda6c.json/default/TopLevel.ts
index 0f8ebec..474e965 100644
--- a/base/typescript/test/inputs/json/misc/cda6c.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/cda6c.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export interface PurpleTopLevel {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -26,7 +28,7 @@ export type ID = "CN" | "SP.POP.TOTL";
 
 export type Value = "China" | "Population, total";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     page:     number;
     pages:    number;
     per_page: string;
@@ -36,12 +38,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
     }
 }
 
@@ -199,7 +201,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -210,7 +212,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/e2a58.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/e2a58.json/default/TopLevel.ts
index 3bc7cba..7ebcd56 100644
--- a/base/typescript/test/inputs/json/misc/e2a58.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/e2a58.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     date:              string;
     "stop-and-search": string[];
 }
@@ -15,12 +17,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -178,7 +180,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "date", js: "date", typ: "" },
         { json: "stop-and-search", js: "stop-and-search", typ: a("") },
     ], false),
diff --git a/base/typescript/test/inputs/json/misc/e53b5.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/e53b5.json/default/TopLevel.ts
index 1a8cc5b..f45d1ca 100644
--- a/base/typescript/test/inputs/json/misc/e53b5.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/e53b5.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel;
+
+export interface PurpleTopLevel {
     country:   Country;
     date:      string;
     decimal:   string;
@@ -26,7 +28,7 @@ export type ID = "IN" | "SP.POP.TOTL";
 
 export type Value = "India" | "Population, total";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     page:     number;
     pages:    number;
     per_page: string;
@@ -36,12 +38,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"))));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"))));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel")))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel")))), null, 2);
     }
 }
 
@@ -199,7 +201,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "country", js: "country", typ: r("Country") },
         { json: "date", js: "date", typ: "" },
         { json: "decimal", js: "decimal", typ: "" },
@@ -210,7 +212,7 @@ const typeMap: any = {
         { json: "id", js: "id", typ: r("ID") },
         { json: "value", js: "value", typ: r("Value") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "page", js: "page", typ: 0 },
         { json: "pages", js: "pages", typ: 0 },
         { json: "per_page", js: "per_page", typ: "" },
diff --git a/base/typescript/test/inputs/json/misc/e8a0b.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/e8a0b.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/e8a0b.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/e8a0b.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/e8b04.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/e8b04.json/default/TopLevel.ts
index 5e257c6..b9ba594 100644
--- a/base/typescript/test/inputs/json/misc/e8b04.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/e8b04.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     averageRating:            number;
     category?:                string;
     createdAt:                number;
@@ -243,12 +245,12 @@ export type ViewType = "tabular";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -406,7 +408,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "averageRating", js: "averageRating", typ: 0 },
         { json: "category", js: "category", typ: u(undefined, "") },
         { json: "createdAt", js: "createdAt", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/f3139.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/f3139.json/default/TopLevel.ts
index 9aee0ae..7d4ac1e 100644
--- a/base/typescript/test/inputs/json/misc/f3139.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/f3139.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     id:   string;
     name: string;
 }
@@ -15,12 +17,12 @@ export interface TopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -178,7 +180,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "id", js: "id", typ: "" },
         { json: "name", js: "name", typ: "" },
     ], false),
diff --git a/base/typescript/test/inputs/json/misc/f3edf.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/f3edf.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/f3edf.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/f3edf.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/misc/f466a.json/default/TopLevel.ts b/head/typescript/test/inputs/json/misc/f466a.json/default/TopLevel.ts
index a94487f..9e75124 100644
--- a/base/typescript/test/inputs/json/misc/f466a.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/misc/f466a.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     age:     number;
     country: Country;
     females: number;
@@ -21,12 +23,12 @@ export type Country = "United States";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -184,7 +186,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "age", js: "age", typ: 0 },
         { json: "country", js: "country", typ: r("Country") },
         { json: "females", js: "females", typ: 0 },
diff --git a/base/typescript/test/inputs/json/priority/bug863.json/default/TopLevel.ts b/head/typescript/test/inputs/json/priority/bug863.json/default/TopLevel.ts
index 92f7813..929b7b1 100644
--- a/base/typescript/test/inputs/json/priority/bug863.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/priority/bug863.json/default/TopLevel.ts
@@ -7,9 +7,11 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export type TopLevel = TopLevelElement[] | PurpleTopLevel | string;
+export type TopLevel = TopLevelUnion[];
 
-export interface TopLevelElement {
+export type TopLevelUnion = PurpleTopLevel[] | FluffyTopLevel | string;
+
+export interface PurpleTopLevel {
     ALIENLEVEL:          number;
     BREED:               Breed;
     CHAR_DIMENSION:      number;
@@ -41,7 +43,7 @@ export type RankTitle = "President" | "Advisor" | "Veteran" | "Applicant";
 
 export type Sex = "Neuter" | "Male" | "Female";
 
-export interface PurpleTopLevel {
+export interface FluffyTopLevel {
     ADVENTURERCOUNT: number;
     AGENTCOUNT:      number;
     ATROXCOUNT:      number;
@@ -82,12 +84,12 @@ export interface PurpleTopLevel {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(u(a(r("TopLevelElement")), r("PurpleTopLevel"), "")));
+    public static toTopLevel(json: string): TopLevelUnion[] {
+        return cast(JSON.parse(json), a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"), "")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(u(a(r("TopLevelElement")), r("PurpleTopLevel"), ""))), null, 2);
+    public static topLevelToJson(value: TopLevelUnion[]): string {
+        return JSON.stringify(uncast(value, a(u(a(r("PurpleTopLevel")), r("FluffyTopLevel"), ""))), null, 2);
     }
 }
 
@@ -245,7 +247,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevelElement": o([
+    "PurpleTopLevel": o([
         { json: "ALIENLEVEL", js: "ALIENLEVEL", typ: 0 },
         { json: "BREED", js: "BREED", typ: r("Breed") },
         { json: "CHAR_DIMENSION", js: "CHAR_DIMENSION", typ: 0 },
@@ -264,7 +266,7 @@ const typeMap: any = {
         { json: "RANK_TITLE", js: "RANK_TITLE", typ: r("RankTitle") },
         { json: "SEX", js: "SEX", typ: r("Sex") },
     ], false),
-    "PurpleTopLevel": o([
+    "FluffyTopLevel": o([
         { json: "ADVENTURERCOUNT", js: "ADVENTURERCOUNT", typ: 0 },
         { json: "AGENTCOUNT", js: "AGENTCOUNT", typ: 0 },
         { json: "ATROXCOUNT", js: "ATROXCOUNT", typ: 0 },
diff --git a/base/typescript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.ts b/head/typescript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.ts
index 879709d..ed09493 100644
--- a/base/typescript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/priority/issue2680-object-array.json/default/TopLevel.ts
@@ -7,19 +7,21 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     key: string;
 }
 
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -177,7 +179,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "key", js: "key", typ: "" },
     ], false),
 };
diff --git a/base/typescript/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.ts b/head/typescript/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.ts
index 9d6098b..5c9d110 100644
--- a/base/typescript/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/priority/issue2680-scalar-array.json/default/TopLevel.ts
@@ -7,6 +7,8 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
+export type TopLevel = number[];
+
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
diff --git a/base/typescript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.ts b/head/typescript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.ts
index 4e8955f..69390b4 100644
--- a/base/typescript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/priority/kotlin-enum-class-case-collision.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     category: Category;
 }
 
@@ -16,12 +18,12 @@ export type Category = " " | "";
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "category", js: "category", typ: r("Category") },
     ], false),
     "Category": [
diff --git a/base/typescript/test/inputs/json/priority/optional-union.json/default/TopLevel.ts b/head/typescript/test/inputs/json/priority/optional-union.json/default/TopLevel.ts
index ed45e67..ed872ef 100644
--- a/base/typescript/test/inputs/json/priority/optional-union.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/priority/optional-union.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     a?: A;
 }
 
@@ -16,12 +18,12 @@ export type A = number | string;
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -179,7 +181,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "a", js: "a", typ: u(undefined, u(0, "")) },
     ], false),
 };
diff --git a/base/typescript/test/inputs/json/samples/github-events.json/default/TopLevel.ts b/head/typescript/test/inputs/json/samples/github-events.json/default/TopLevel.ts
index 68bdc1c..946d61e 100644
--- a/base/typescript/test/inputs/json/samples/github-events.json/default/TopLevel.ts
+++ b/head/typescript/test/inputs/json/samples/github-events.json/default/TopLevel.ts
@@ -7,7 +7,9 @@
 // These functions will throw an error if the JSON doesn't
 // match the expected interface, even if the JSON is valid.
 
-export interface TopLevel {
+export type TopLevel = TopLevelElement[];
+
+export interface TopLevelElement {
     actor:      Actor;
     created_at: Date;
     id:         string;
@@ -298,12 +300,12 @@ export interface TopLevelRepo {
 // Converts JSON strings to/from your types
 // and asserts the results of JSON.parse at runtime
 export class Convert {
-    public static toTopLevel(json: string): TopLevel[] {
-        return cast(JSON.parse(json), a(r("TopLevel")));
+    public static toTopLevel(json: string): TopLevelElement[] {
+        return cast(JSON.parse(json), a(r("TopLevelElement")));
     }
 
-    public static topLevelToJson(value: TopLevel[]): string {
-        return JSON.stringify(uncast(value, a(r("TopLevel"))), null, 2);
+    public static topLevelToJson(value: TopLevelElement[]): string {
+        return JSON.stringify(uncast(value, a(r("TopLevelElement"))), null, 2);
     }
 }
 
@@ -461,7 +463,7 @@ function r(name: string) {
 }
 
 const typeMap: any = {
-    "TopLevel": o([
+    "TopLevelElement": o([
         { json: "actor", js: "actor", typ: r("Actor") },
         { json: "created_at", js: "created_at", typ: Date },
         { json: "id", js: "id", typ: "" },
