Deprecated APIs should not be used typescript:S1874

Hi
I’m using typescript version 4.6.2.
Yes, I’m using the createElement method at two locations.

// #1: ts
const downloadLink = document.createElement('a');
// #2: spec.ts
const mockElement = {} as HTMLAnchorElement;
jest.spyOn(document, 'createElement').mockImplementation(() => {
    return mockElement;
});
expect(document.createElement).toHaveBeenCalledTimes(1);

#2 is the test code(by jest) of #1.

I don’t have any problem with #1.
In case of #2, typescript reports nothing, but sonarqube reports that “The method is deprecated” at bold context below.

expect(document.createElement).toHaveBeenCalledTimes(1);

  • ‘createElement’ is deprecated.
  • Deprecated APIs should not be used typescript:S1874

I found a similar thread that was not resolved in the past.

What my case and Patrik’s case have in common is that we used ‘document.createElement’ without parenthesis.

  • if(document.createElement(‘a’)) → sonarqube does not complain
  • if(document.createElement) → sonarqube complains!