Newbee Q: How is the implementation file for a declaration file resolved?

Topics: General
Apr 18, 2013 at 8:17 PM
I am trying to understand how to use references with declaration files but am having newbee problems. I have one file "app.ts" that references a declaration file "assert.d.ts" located in a sub directory. This compiles fine but at runtime the implementation file "assert.js" is not found even though it is next to the declaration file. I arranged my files like this:

/// <reference path='./lib/assert.d.ts' />
import assert = module("assert");
module "assert" {
    function condition(o);
define(["require", "exports"], function (require, exports) {
    function condition(o) {
    exports.condition = condition;
If I move the assert files into the same directory as app.js then everything works. However I'd like to move 3ed party libraries into a separate lib folder. How can I do this?

Apr 23, 2013 at 12:48 AM
The assert.js that you're trying to load will need to be visible to the module loader you're using. The file path you're declaring is what's (I believe) relative to the .js file being loaded, though it's been a little while since I've tried it.

You can use TypeScript to also create the external module rather than trying to load an existing one via the .js file as well. This might be a simpler option if you're starting from scratch.