mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #24205 from saschanaz/webidl2-const
fix(webidl2): idlType is IDLTypeDescription
This commit is contained in:
Vendored
+5
-4
@@ -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. */
|
||||
@@ -191,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[];
|
||||
}
|
||||
@@ -218,8 +219,8 @@ export interface ConstantMemberType {
|
||||
type: "const";
|
||||
/** Whether its type is nullable. */
|
||||
nullable: boolean;
|
||||
/** The type of the constant (a simple type, the type name). */
|
||||
idlType: string;
|
||||
/** An IDL Type of the constant that represents a simple type, the type name. */
|
||||
idlType: IDLTypeDescription;
|
||||
/** The name of the constant. */
|
||||
name: string;
|
||||
/** The constant value */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user