In Typescript, how can I use functions defined in another TS file without puting them in a module?
function, typescript
Solution
You can put any code in a file, it doesn't have to be a module.
Here is Library.ts:
var globalVariable = 'Hello World';
function globalFunction() {
alert(globalVariable);
}
And here is app.ts:
/// <reference path="library.ts" />
globalFunction();
Problem
I need to use functions defined in a TS file, a file that I'll call "library.ts". I need to use these functions in another file "main.ts". However, for good non-technical reasons (education), I do not want the user to have to know about modules. For example, I just want them to be able to call ReadText/WriteText without having to worry about a module. X.ReadText is unacceptable. How can I call a function defined not within a module in library.ts from a function in main.ts? My VS project says I'm using Typescript 1.1 (TypeScriptToolsVersion)