I am building a project in Typescript using Atom as my text editor. I have atom-typescript installed, which is compiling my code to JavaScript automatically.
What I am attempting to do is define a new extension method on type string to determine if it is null or blank. I have a main file which exports a single function, and a mocha test attempting to verify it is all working. The issue I am running into is that mocha is throwing a type error:String.isNullOrEmpty is not a function
Here is my stringExtensions.ts:
interface StringConstructor {
isNullOrEmpty(str: string): boolean;
}
String.isNullOrEmpty = function(str: string): boolean{
return (!str || 0 === str.length);
}
In my main.ts I have the following code:
///<reference path="extensions/stringExtensions.ts"/>
export function checkForUpdate(){
if(String.isNullOrEmpty(location)){
/* Do Stuff */
}
In main.spec.ts
import {checkForUpdate} from "../lib/update"
describe("test", ()=>{
if("should do something", ()=>{
checkForUpdate();
})
})
If I copy my code from the extension file into the main file everything is working fine so I know this is a reference problem. Atom-typescript is throwing no errors, it is able to find the code just fine and everything looks good on its end.
What modifications do I need to make to have the reference work correctly. I am looking at the compiled JavaScript code and there is no import instruction from my reference command. Should there be?