Modified Mousetrap definition to allow Mousetrap to be loaded as an

external module.

- tests are also updated to test loading as an external module
- mousetrap exports itself as an AMD module when an AMD define function is
  present
This commit is contained in:
Andrew Bradley
2014-11-06 01:31:01 -05:00
parent a0e56c27e7
commit 1d556e1d7c
2 changed files with 12 additions and 0 deletions

View File

@@ -41,3 +41,11 @@ Mousetrap.trigger('esc');
Mousetrap.trigger('esc', 'keyup');
Mousetrap.reset();
// Test that Mousetrap can be loaded as an external module.
// Assume that if the externally-loaded module can be assigned to a variable with the type of global Mousetrap,
// then everything is working correctly.
import importedMousetrap = require('mousetrap');
var mousetrapModuleReference: typeof Mousetrap = importedMousetrap;

View File

@@ -19,3 +19,7 @@ interface MousetrapStatic {
}
declare var Mousetrap: MousetrapStatic;
declare module "mousetrap" {
export = Mousetrap;
}