I am using typescript in AMD mode (using requirejs).
Let's say I want to add a function to String, at the moment I do:
Extensions/String.ts
interface String {
startsWith(str: string): boolean;
}
define(() => {
String.prototype.startsWith = function (str)
{
return (this.match("^" + str) == str);
};
});
This works and generate the right .js file and I am able to use in non-typescript requirejs modules.
How do I "import" this requirejs module in a typescript class?
In the file of the class that wants to use the new functions, this doesn't work:
types/SampleClass.ts
import ExtensionsString = require("Extensions/String");
I get this error:
"unable to resolve external module '"Extensions/String"'
How can I make typescript add "Extensions/String" to the list of dependencies
types/SampleClass.js
define("SampleClass", ["Extensions/String"], function(/* no need to have parameter */){
...
});
Thanks for your help!
declare module "Extensions/String" { ... }
– Stephen Chung Jun 7 '14 at 10:13