From 9b073d0f81a128a3d4a67a5889f8a72a1bdb630a Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Sun, 14 Jun 2015 01:05:09 -0400 Subject: [PATCH] Fix #4620: Add module declaration for 'module' magic module --- requirejs/require-tests.ts | 8 ++++++++ requirejs/require.d.ts | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/requirejs/require-tests.ts b/requirejs/require-tests.ts index a8cfdc87e0..0f3cc8194f 100644 --- a/requirejs/require-tests.ts +++ b/requirejs/require-tests.ts @@ -41,3 +41,11 @@ require(['main'], (main: any, $: any, _: any, Backbone: any) => { var recOne = require.config({ baseUrl: 'js' }); recOne(['core'], function (core: any) {/*some code*/}); +// Tests for 'module' magic module typings +// (Using 'module' only actually makes sense in an external module) + +import module = require('module'); + +var moduleConfig: any = module.config(); +var moduleId: string = module.id; +var moduleUri: string = module.uri; diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index 47c754c602..21f9aeebb7 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -29,6 +29,15 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +declare module 'module' { + var mod: { + config: () => any; + id: string; + uri: string; + } + export = mod; +} + interface RequireError extends Error { /** @@ -342,7 +351,7 @@ interface RequireDefine { * callback return module definition **/ (name: string, ready: Function): void; - + /** * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object.