如何用null代替javascript测试方法的严格类型参数

如何用null代替javascript测试方法的严格类型参数,javascript,testing,types,null,Javascript,Testing,Types,Null,我有一些方法: someMethod(userId: string): string { if(userId === null) { throw SomeError } ... } 和测试: it('#someMetho with invalid parameters', () => { someMethod(null).catch((error: any) => { expect(error).toEqual(SomeErro

我有一些方法:

someMethod(userId: string): string {

 if(userId === null) {
   throw SomeError
 }

 ...
}
和测试:

it('#someMetho with invalid parameters', () => {
        someMethod(null).catch((error: any) => {
           expect(error).toEqual(SomeError);
        });
    });
并得到一个警告,类型为null的参数不能分配给类型为string的参数


如何在测试中避免此警告?

someMethod(userId:string | null)
我无法更改源代码,因此您不应该测试它。