-
Notifications
You must be signed in to change notification settings - Fork 12.8k
CSSStyleDeclaration string properties all have | null
type declaration.
#13644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Since this is strictly not per spec, we would like to get some more user feedback to warrant the change. |
Just as a curiosity, why were the |
The libraries are generated from a WebIDL, with overrides. I believe it is still the WebIDL from Edge, though there was a desire to generate it from the spec. There is seldom any feedback required to make something more compliant with the spec and in many cases it is automatic as the upstream "authority" gets updated. The generator is available at Microsoft/TSJS-lib-generator, which includes the current version of the spec files it uses. |
It's very interesting to know this, thanks! I didn't know such level of automation was in place. This is then definitely related with the issue I just opened about missing HTML tags. |
Currently we have mixed |
Perhaps already fixed around here?: |
Looks like this has landed in TS 3.6.4 |
lib.dom.d.ts
has recently suffixed all of the properties ofCSSStyleDeclaration
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 specnull
will never be returned, only an empty string:https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue
The spec does seem to allow
null
as an argument forsetPropertyValue
, 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 everywhereCSSStyleDeclaration
is used.The text was updated successfully, but these errors were encountered: