Skip to content

Commit ef05e36

Browse files
committed
add dangling types to the genericless schema
1 parent ea0fb77 commit ef05e36

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

compiler/src/transform/expand-generics.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ export function expandGenerics (inputModel: Model): Model {
134134
}
135135
}
136136

137+
/**
138+
* Add dangling types like CommonQueryParameters & BaseEsqlVersion to the generic less schema.
139+
* @param type the type definition
140+
*/
141+
function addDanglingTypeIfNotSeen(type: TypeDefinition) {
142+
switch (type.kind) {
143+
case "type_alias":
144+
if (type.generics !== undefined && type.generics.length > 0) {
145+
return;
146+
}
147+
case "interface":
148+
if (type.generics !== undefined && type.generics.length > 0) {
149+
return;
150+
}
151+
}
152+
addIfNotSeen(type.name, () => type)
153+
}
154+
137155
/**
138156
* Expand an interface definition.
139157
*
@@ -361,6 +379,10 @@ export function expandGenerics (inputModel: Model): Model {
361379
expandRootType(endpoint.response)
362380
}
363381

382+
for (const type of inputModel.types) {
383+
addDanglingTypeIfNotSeen(type);
384+
}
385+
364386
sortTypeDefinitions(types)
365387

366388
return {

0 commit comments

Comments
 (0)