0

The below code throws error after upgrading to "@types/jasmine": "^3.4.0"

spyOn(document, 'getElementById').and.callFake(function() {
      return {
        value: 'test'
      };
    });

Error is:

Argument of type '() => { value: string; }' is not assignable to parameter of type '(elementId: string) => HTMLElement'.
  Type '{ value: string; }' is missing the following properties from type 'HTMLElement': accessKey, accessKeyLabel, autocapitalize, dir, and 233 more.
Ashutosh Singh
  • 269
  • 1
  • 2
  • 9

1 Answers1

0

Try casting to fix the issue.

spyOn(document, 'getElementById').and.callFake(function(elementId: string) {
      return {
        value: 'test'
      } as HTMLElement;
    });
AliF50
  • 16,947
  • 1
  • 21
  • 37