-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
lib.dom.d.ts has recently suffixed all of the properties of CSSStyleDeclaration with | null:
https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L1382
6814c1d
For those of us using --strictNullChecks, this is forcing a null assertion (!) every time a property is used, even though according to the spec null will never be returned, only an empty string:
https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue
The camel-cased attribute attribute, on getting, must return the result of invoking getPropertyValue() with the argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute.
The spec does seem to allow null as an argument for setPropertyValue, so technically this a case where allowing a different type for a getter and setter (#2521) would be required to accurately model a builtin.
But in the absence of that, this particular object treats the empty string the same as null for setting, so I think it would be cleaner to simply remove | null from this definition so that we don't have to needlessly null-assert everywhere CSSStyleDeclaration is used.