diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 7fe2c8824..c7ccd5d4e 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -400,7 +400,6 @@ "name": "StyleMedia", "exposed": "Window", "noInterfaceObject": true, - "deprecated": true, "properties": { "property": { "type": { diff --git a/inputfiles/patches/cssom.kdl b/inputfiles/patches/cssom.kdl index a3baf2c5c..fdb03b695 100644 --- a/inputfiles/patches/cssom.kdl +++ b/inputfiles/patches/cssom.kdl @@ -7,3 +7,5 @@ interface CSSStyleDeclaration \ forwardExtends=CSSStyleProperties interface CSSStyleProperties replaceReference=CSSStyleDeclaration + +interface StyleMedia deprecated=#true diff --git a/src/build/patches.ts b/src/build/patches.ts index 6bf60fa05..3a31e0d95 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -15,12 +15,16 @@ type DeepPartial = T extends object ? { [K in keyof T]?: DeepPartial } : T; -function optionalMember(prop: string, type: T, value?: Value) { +function optionalMember(prop: string, type: T | T[], value?: Value) { if (value === undefined) { return {}; } - if (typeof value !== type) { - throw new Error(`Expected type ${value} for ${prop}`); + const types = Array.isArray(type) ? type : [type]; + const valueType = typeof value; + if (!types.includes(valueType as T)) { + throw new Error( + `Expected type ${types.join(" or ")} for ${prop}, but got ${valueType}`, + ); } return { [prop]: value as T extends "string" @@ -169,7 +173,11 @@ function handleMixinandInterfaces( const interfaceObject = type === "interface" && { ...optionalMember("exposed", "string", node.properties?.exposed), - ...optionalMember("deprecated", "string", node.properties?.deprecated), + ...optionalMember( + "deprecated", + ["string", "boolean"], + node.properties?.deprecated, + ), ...optionalMember( "noInterfaceObject", "boolean",