Imports left out of module dependencies when not directly assigned or assigned to. · Issue #2132 · microsoft/TypeScript (original) (raw)
In the following case a module defined in TypeScript will not be included in the required modules of the module.
import something = require('Something');
angular.module('app')
.controller('somethingController', [
'definedInSomething', function (definedInSomething: something.myInterfaceOrType) {
definedInSomething; //Not defined, and not reached because 'definedInSomething' was not included
}
]);
The module that is generated is:
define(["require", "exports"], function(require, exports) {
Instead of:
define(["require", "exports", 'Something'], function(require, exports, Something) {
Assigning something
to another value or accessing the properties of something
will cause it to be added to the module signature.
In any case the values defined in the import x = require('y')
should be added to the module dependencies. The author has explicitly added the reference and as such has an expectation that it will be included in the dependencies of the current module.