Most .d.ts files are straightforward to use, jQuery.d.ts for instance. But now I have hit up against chrome-app.d.ts and it isn't clear (to me!) how this typings file can be imported. chrome-app.d.ts comprises a series of module definitions, each containing interfaces and exported functions. Here is a snip:
declare module chrome.app.runtime {
interface LaunchData {
id?: string;
......
......
}
declare module chrome.app.window {
interface ContentBounds {
left?: number;
......
......
export function current(): AppWindow;
export function get(id: string): AppWindow;
export function getAll(): AppWindow[];
}
and so on, seven modules in total. The module names are not quoted. There is no top level export declaration.
How can I use (i.e. import) this definition file in my ts? I would like to use chrome.app.window.get() and so on, staying with the JS definitions in the Goog documentation. SO answer Using a Typescript .d.ts file that doesn't declare a module nearly works for my problem. In that solution, add to a supplementary .d.ts file with a quoted module name:
declare module 'chrome.app.runtime' { export = chrome.app.runtime; }
and indeed I can use this:
import chromeAppRuntime = require('chrome.app.runtime');
but I cannot use this:
import chrome.app.runtime = require('chrome.app.runtime');
So would this be OK and preserve the tool chain:
import fooBar = require('chrome.app.runtime');
var chrome = {app: {runtime: fooBar}};
Is there anything simpler :)