Microsoft/TypeScript
Ver no GitHubExternal modules with AMD always requires "exports" even when it is not used
Open
#669 aberto em 12 de set. de 2014
Help WantedSuggestion
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
Here's a small external module that explicitly exports a module:
module Foo {
export var foo = 42;
}
export = Foo;
The code generated for this is:
define(["require", "exports"], function(require, exports) {
var Foo;
(function (Foo) {
Foo.foo = 42;
})(Foo || (Foo = {}));
return Foo;
});
This feels like bad AMD since you are requiring the "exports" magic dependency, but then not using it and instead returning Foo directly.
It's annoying for minimal AMD loaders since they can't assume the object return of your module is your "exports" object and have to guess that you really meant to return something that overrode the "exports" object you asked for.
Furthermore, why bother declaring a dependency on 'require' when it's not used?