diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index a2771c698..7f6837563 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -327,21 +327,6 @@ }, "interfaces": { "interface": { - "CryptoKey": { - "properties": { - "property": { - "algorithm": { - "type": "KeyAlgorithm" - }, - "usages": { - "type": "sequence", - "subtype": { - "type": "KeyUsage" - } - } - } - } - }, "GPUPipelineError": { // Web IDL optional argument can be followed by a required argument, but not in TS // TODO: Maybe do this in the emitter? diff --git a/inputfiles/patches/crypto.kdl b/inputfiles/patches/crypto.kdl index 05587ef2e..51aca43a2 100644 --- a/inputfiles/patches/crypto.kdl +++ b/inputfiles/patches/crypto.kdl @@ -3,3 +3,12 @@ dictionary CryptoKeyPair { member privateKey required=#true member publicKey required=#true } + +interface CryptoKey { + property algorithm type=KeyAlgorithm + property usages { + type sequence { + type KeyUsage + } + } +} diff --git a/src/build/patches.ts b/src/build/patches.ts index df0b3a881..f792bafa1 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -232,12 +232,22 @@ function handleEvent(child: Node): Event { * @param child The child node to handle. */ function handleProperty(child: Node): Partial { + let typeNode: Node | undefined; + for (const c of child.children) { + if (c.name === "type") { + typeNode = c; + break; + } + } + return { name: string(child.values[0]), ...optionalMember("exposed", "string", child.properties?.exposed), ...optionalMember("optional", "boolean", child.properties?.optional), ...optionalMember("overrideType", "string", child.properties?.overrideType), - ...optionalMember("type", "string", child.properties?.type), + ...(typeNode + ? handleTyped(typeNode) + : optionalMember("type", "string", child.properties?.type)), ...optionalMember("readonly", "boolean", child.properties?.readonly), ...optionalMember("deprecated", "boolean", child.properties?.deprecated), };