Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
When trying to mock the implementation of getCredentials in Jest, the following code in TypeScript (using strict mode) will fail:
const impl = jest.spyOn(AWS.config, 'getCredentials').mockImplementation(
cb => cb(null), // Argument of type 'null' is not assignable to parameter of type 'AWSError'
);
The signature of function getCredentials:
https://github.com/aws/aws-sdk-js/blob/319f32535d18003fce3bf9d103656b2defb7ff4c/lib/config.d.ts#L13
should be:
getCredentials(callback: (err: AWSError | null) => void): void;
Is the issue in the browser/Node.js?
N/A
If on Node.js, are you running this on AWS Lambda?
Details of the browser/Node.js version
N/A
SDK version number
v2.647.0
master
To Reproduce (observed behavior)
import * as AWS from 'aws-sdk';
AWS.config.getCredentials(err => {
// In strict mode TypeScript should report an error, but doesn't because err can never be null.
err.stack
});
Expected behavior
In the reproduce section above, you should have a TypeScript compilation error but you don't.
@Nemikolh Thank-you for reaching out and providing the PR as well, will have someone review it soon.
I think this was fixed in 89640c2f66245d2ac5a659a10c2d186e7fc87a99
Most helpful comment
I think this was fixed in 89640c2f66245d2ac5a659a10c2d186e7fc87a99