I've switched an angular 1 typescript project over to TS 2.0 and am using @types/angular-mocks for the type definitions. As it stands, i'm unable to work out how to actually import and use angular-mocks 'module', without getting TS errors.
All three of these ways actually work (as in, my tests run without any errors, after being transpiled and loaded by systemjs), but they all result in TS errors
1)
import {module} from 'angular-mocks';
beforeEach(module('blah'));
systemjs config meta:
meta: {
angular: {
format: 'global',
exports: 'angular'
},
'angular-mocks': {
format: 'global',
deps: ['angular']
}
}
TS error:
error TS2305: Module '"/path/to/node_modules/@types/angular-mocks/index"' has no exported member 'module'.
2)
import * as angular from 'angular-mocks';
beforeEach(angular.mock.module('blah'));
systemjs config meta:
meta: {
angular: {
format: 'global',
exports: 'angular'
},
'angular-mocks': {
format: 'global',
exports: 'angular',
deps: ['angular']
}
}
TS error:
error TS2339: Property 'mock' does not exist on type 'typeof "/path/to/node_modules/@types/angular...'.
3)
import 'angular-mocks';
beforeEach(module('blah'));
systemjs config meta:
meta: {
angular: {
format: 'global',
exports: 'angular'
},
'angular-mocks': {
format: 'global',
deps: ['angular']
}
}
TS Error:
error TS2304: Cannot find name 'module'.
------------------------------------------------------------------------
So i'm wondering what's the correct way to do this to prevent TS errors?
Cheers.