Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:08:13+00:00 2026-06-13T07:08:13+00:00

I have a module that depends on Backbone . I have a backbone.d.ts definition

  • 0

I have a module that depends on Backbone. I have a backbone.d.ts definition but TypeScript doesn’t seem to want to compile my module unless my

import Backbone = module("backbone")

actually points to a valid backbone module as opposed to a definition file. I am using AMD loaded modules and have a requirejs shim defined for backbone.

Is there a workaround besides creating a phoney backbone.ts module definition?

Update: A side effect of the solution is that code such as this no longer works because the module no longer exists. It needs to exist because of the requirejs shim. The only workaround I know of is to have two .d.ts files. One for the file using backbone as an import that does not include the declare module bit. The other for using a /// <reference that does include the declare module line.

/// <reference path="../dep/backbone/backbone.d.ts" />

interface IApi {
    version: number;
    Events: Backbone.Events;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:08:14+00:00Added an answer on June 13, 2026 at 7:08 am

    The TypeScript language has changed a fair bit since this original answer.

    For example, to import an external module you use require (my original answer had the old module keyword):

    Here is a common use case for importing backbone – using the type information from Definitely Typed:

    /// <reference path="scripts/typings/backbone/backbone.d.ts" />
    
    import bb = require('backbone');
    

    Within the type definition, the backbone module is declared for you, which is what allows the import to be valid:

    //... lots of code and then...
    
    declare module "backbone" {
        export = Backbone;
    }
    

    So the original question could be resolved using…

    /// <reference path="scripts/typings/backbone/backbone.d.ts" />
    
    import bb = require('backbone');
    
    interface IApi {
        version: number;
        Events: bb.Events;
    }
    
    class Api implements IApi {
        public version = 1;
        public Events: bb.Events = null;
    }
    

    For this code example, this is all that is required – but more often you will want the backbone library loaded at runtime… you can use the (officially experimental) amd-dependency comment to cause the generated define function call to include backbone.

    /// <reference path="scripts/typings/backbone/backbone.d.ts" />
    /// <amd-dependency path="backbone" />
    
    import bb = require('backbone');
    
    interface IApi {
        version: number;
        Events: bb.Events;
    }
    
    class Api implements IApi {
        public version = 1;
        public Events: bb.Events = null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compile/install a Perl module that depends on a library that is
Suppose you have a module that you know is safe. You want to mark
I have this module pattern that stores a bunch of vars. I want to
I have a muti-module maven project, and I created a new module that depends
If you have a modular applicaiton that depends on its modules to be in
I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
I have a module that is being used to create only a few page
I have a module that reads the StandardError of a process. Everything works fine,
Let's say that I have a module that has a Queue in it. For
I have a war module that is being built and is including a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.