Problem with use of ambient declaration file

Topics: General
Oct 22, 2012 at 6:04 PM
Edited Oct 22, 2012 at 6:06 PM

I have two scenarios in which I want to use a backbone.d.ts ambient declaration. The first is a definition file for intellisense of a plain js file I do not wish to convert to typescript. The second is a module that extends Backbone.Model and will be used by my view.

My definition file:

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

interface IApi {
    version: number;
    Events: Backbone.Events;
}

declare var api: IApi;

My module:

import Backbone = module("../../../dep/backbone/backbone");

export class Codebook extends Backbone.Model {

    defaults() {
        return {
            id: -1,
            title: -1
        }
    }

    initialize() {
        // do nothing
    }

}

The problem is that the definition file requires that the backbone.d.ts file include a module declaration: declare module Backbone. The module requires that this line be omitted in order to use the Backbone import and extend from it.