TypeScript Version: 3.3.0-dev.20181128, 3.2.0-rc (does not repro in 3.1.6)
Search Terms:
keyof module, default, spyOn, jest
Code
// example.ts
export default function add(a: number, b: number) {
return a + b;
}
//exampleTest.ts
import * as example from '../example';
describe('add', () => {
it('does something', () => {
spyOn(example, 'default');
})
})
Uses @types/jest@23.3.9, with the following declaration:
declare function spyOn<T>(object: T, method: keyof T): jasmine.Spy;
Expected behavior:
spyOn(example, 'default') throws no errors, as the only export from the example.ts module is a default export.
Actual behavior:
src/__tests__/exampleTest.ts:5:24 - error TS2345: Argument of type '"default"' is not assignable to parameter of type '"add"'.
Playground Link: None; the playground doesn't seem to support multiple modules
Related Issues: None that I could find.
TypeScript Version: 3.3.0-dev.20181128, 3.2.0-rc (does not repro in 3.1.6)
Search Terms:
keyof module, default, spyOn, jest
Code
Uses
@types/jest@23.3.9, with the following declaration:Expected behavior:
spyOn(example, 'default')throws no errors, as the only export from theexample.tsmodule is a default export.Actual behavior:
Playground Link: None; the playground doesn't seem to support multiple modules
Related Issues: None that I could find.