What is the expected behavior?
The following example should compile:
import * as nock from 'nock';
interface Body {
param: number;
}
const body: Body = {
param: 1,
};
const scope = nock('http://example.test')
.post('/users', body)
.reply(200);
What is the actual behavior?
Typescript does not allow this, because it can not infer an interface as a dictionary.
({ [k: string]: ... }) if it is not explicitly intended as one. More on this issue here microsoft/TypeScript#15300 and here.
The following error is thrown upon compilation:
Argument of type 'Body' is not assignable to parameter of type 'string | RegExp | Buffer | DataMatcher | ((body: any) => boolean) | undefined'.
Type 'Body' is not assignable to type 'DataMatcher'.
Index signature is missing in type 'Body'.
Possible solution
How to reproduce the issue
The latest typescript definitions are not yet released which are required for this to reproduce. The example above can be run instead.
Does the bug have a test case?
Versions
| Software |
Version(s) |
| Nock |
master |
| Node |
10 |
What is the expected behavior?
The following example should compile:
What is the actual behavior?
Typescript does not allow this, because it can not infer an interface as a dictionary.
(
{ [k: string]: ... }) if it is not explicitly intended as one. More on this issue here microsoft/TypeScript#15300 and here.The following error is thrown upon compilation:
Possible solution
How to reproduce the issue
The latest typescript definitions are not yet released which are required for this to reproduce. The example above can be run instead.
Does the bug have a test case?
Versions