From 183fd0a5bcb6c9218a2316310f05f837081ab478 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sat, 10 Mar 2018 23:13:14 +0900 Subject: [PATCH 1/3] fix(webidl2): idlType is IDLTypeDescription --- types/webidl2/index.d.ts | 2 +- types/webidl2/webidl2-tests.ts | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/types/webidl2/index.d.ts b/types/webidl2/index.d.ts index 0dd0cc7f10..f3ca7ff3e4 100644 --- a/types/webidl2/index.d.ts +++ b/types/webidl2/index.d.ts @@ -219,7 +219,7 @@ export interface ConstantMemberType { /** Whether its type is nullable. */ nullable: boolean; /** The type of the constant (a simple type, the type name). */ - idlType: string; + idlType: IDLTypeDescription; /** The name of the constant. */ name: string; /** The constant value */ diff --git a/types/webidl2/webidl2-tests.ts b/types/webidl2/webidl2-tests.ts index 61b437f563..a1c3165edf 100644 --- a/types/webidl2/webidl2-tests.ts +++ b/types/webidl2/webidl2-tests.ts @@ -64,23 +64,27 @@ function logMembers(members: webidl2.IDLInterfaceMemberType[]) { break; case "const": console.log(member.name); + logIdlType(member.idlType); console.log(member.value); console.log(member.nullable); break; case "iterable": console.log(member.readonly); + member.idlType.forEach(logIdlType); break; case "legacyiterable": console.log(member.readonly); + member.idlType.forEach(logIdlType); break; case "setlike": console.log(member.readonly); + member.idlType.forEach(logIdlType); break; case "maplike": console.log(member.readonly); + member.idlType.forEach(logIdlType); break; } - logIdlType(member.idlType); logExtAttrs(member.extAttrs); } } @@ -120,7 +124,13 @@ function logArguments(args: webidl2.Argument[]) { } } -function logIdlType(idlType: string | webidl2.IDLTypeDescription | webidl2.IDLTypeDescription[] | null) { +function logIdlType(idlType: webidl2.IDLTypeDescription) { + console.log(idlType.type); + console.log(idlType.generic, idlType.nullable, idlType.sequence, idlType.union); + logSubIdlType(idlType.idlType); +} + +function logSubIdlType(idlType: string | webidl2.IDLTypeDescription | webidl2.IDLTypeDescription[] | null) { if (!idlType) { return; } @@ -130,15 +140,9 @@ function logIdlType(idlType: string | webidl2.IDLTypeDescription | webidl2.IDLTy } if (Array.isArray(idlType)) { for (const t of idlType) { - logEachType(t); + logIdlType(t); } return; } - logEachType(idlType); - - function logEachType(t: webidl2.IDLTypeDescription) { - console.log(t.type); - console.log(t.generic, t.nullable, t.sequence, t.union); - logIdlType(t.idlType); - } + logIdlType(idlType); } From f7682be37fe3a1ad3f5bae2628fbf4c66329c1ac Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sun, 11 Mar 2018 11:30:45 +0900 Subject: [PATCH 2/3] update idl type documentation --- types/webidl2/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/webidl2/index.d.ts b/types/webidl2/index.d.ts index f3ca7ff3e4..a31fa3550e 100644 --- a/types/webidl2/index.d.ts +++ b/types/webidl2/index.d.ts @@ -33,7 +33,8 @@ export interface WebIDLParseError { // tslint:disable-next-line interface-name export interface IDLTypeDescription { - type: string; + /** String indicating where this type is used. Can be null if not applicable. */ + type: string | null; /** Boolean indicating if it is a sequence. Same as generic === "sequence" */ sequence: boolean; /** String indicating the generic type (e.g. "Promise", "sequence"). null otherwise. */ @@ -218,7 +219,7 @@ export interface ConstantMemberType { type: "const"; /** Whether its type is nullable. */ nullable: boolean; - /** The type of the constant (a simple type, the type name). */ + /** An IDL Type of the constant that represents a simple type, the type name. */ idlType: IDLTypeDescription; /** The name of the constant. */ name: string; From 9ac108dbc2bcc3bbf2ef35ac2915b580149a8188 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 12 Mar 2018 17:59:14 +0900 Subject: [PATCH 3/3] arguments cannot be null --- types/webidl2/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webidl2/index.d.ts b/types/webidl2/index.d.ts index a31fa3550e..9992642749 100644 --- a/types/webidl2/index.d.ts +++ b/types/webidl2/index.d.ts @@ -192,7 +192,7 @@ export interface OperationMemberType { /** The name of the operation. If a stringifier, may be null. */ name: string | null; /** An array of arguments for the operation. */ - arguments: Argument[] | null; + arguments: Argument[]; /** A list of extended attributes. */ extAttrs: ExtendedAttributes[]; }