Skip to content

Commit 492b3b4

Browse files
committed
Supports opptinal name
1 parent 839d07b commit 492b3b4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/build/patches.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@ function string(arg: unknown): string {
4848
return arg;
4949
}
5050

51-
function handleTyped(type: Node): Typed {
51+
function handleTyped(type: Node): DeepPartial<Typed> {
5252
const isTyped = type.name == "type";
5353
if (!isTyped) {
5454
throw new Error("Expected a type node");
5555
}
56-
const name = string(type.values[0]);
5756
const subType =
5857
type.children.length > 0 ? handleTyped(type.children[0]) : undefined;
5958
return {
60-
type: name,
59+
...optionalMember("type", "string", type.values[0]),
6160
subtype: subType,
6261
...optionalMember("nullable", "boolean", type.properties?.nullable),
6362
};
@@ -167,7 +166,7 @@ function handleMixinAndInterfaces(
167166
const name = string(node.properties?.name || node.values[0]);
168167

169168
const event: Event[] = [];
170-
const property: Record<string, Partial<Property>> = {};
169+
const property: Record<string, DeepPartial<Property>> = {};
171170
let method: Record<string, DeepPartial<OverridableMethod>> = {};
172171
let typeParameters = {};
173172

@@ -246,7 +245,7 @@ function handleEvent(child: Node): Event {
246245
* Handles a child node of type "property" and adds it to the property object.
247246
* @param child The child node to handle.
248247
*/
249-
function handleProperty(child: Node): Partial<Property> {
248+
function handleProperty(child: Node): DeepPartial<Property> {
250249
let typeNode: Node | undefined;
251250
for (const c of child.children) {
252251
if (c.name === "type") {

0 commit comments

Comments
 (0)