Is there a way to import or annotate Typescript modules such that external AMD modules will automatically be included as dependencies when generating an AMD-compatible module?:
tsc --module AMD example.ts
I've tried to include both including a reference *.d.ts file, and exporting declare statements:
///<reference path='./lib/knockout-2.2.d.ts' />
export declare var $;
export declare var _;
export module example {
export class Example {
// whatever
}
}
However the generated module does not include these:
define(["require", "exports"], function(require, exports) {
(function (example) {
var Example = (function () {
function Example() { }
return Example;
})();
example.Example = Example;
})(exports.example || (exports.example = {}));
var example = exports.example;
})
Would really like to avoid creating "fake" modules here.
It seems like a nice solution and usage would be to allow importing AMD modules directly:
var $ = import('jquery'); // This is a requirejs/AMD module, not a typescript file.
but I don't know how feasible that is.
Edit:
And I've also tried this approach mentioned here: Import TypeScript module using only ambient definition for use in amd
import knockout = module("./lib/knockout-2.2.d.ts");
...
but get these compiler errors:
example.ts(1,32): The name '"./lib/knockout-2.2.d.ts"' does not exist in the current scope
example.ts(1,32): A module cannot be aliased to a non-module type
tsc --out) instead of worrying about AMD, since wasn't lazy-loading anything. - 7zark7