JavaScript: document.createElement incorrectly reported as deprecated

There are no reports of createElement being deprecated. SonarQube might report this as deprecated because one of the overloads is deprecated, but the method is still available as per spec. The deprecated overload is in relation of it being used when trying to create a listing or xmp element.

window.document.createElement

There is no deprecated tag in the MDN docs: Document.createElement() - Web APIs | MDN

TypeScript project has had similar issue raised document.createElement always marked deprecated · Issue #39212 · microsoft/TypeScript · GitHub

Hi Patrik,

Welcome to the SonarSource community.

Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)?

Would you like to upload a simple zipped project with the bug?

I was not able to reproduce this using SonarQube 8.9.


Regards,
Monty

Hi Monty,

I cannot provide you a zip file of the project however, this is the offending line:

export const isBrowser = (): boolean =>
  !!(typeof window !== 'undefined' && window.document && window.document.createElement);

And, as I mentioned, it gets picked up because one of the overloads is deprecated as per the below screenshot.

I am using SonarLint v3.3.3, SonarQube Enterprise Edition Version 9.3 (build 51899)

Cheers,
Patrik