I am not sure, but I think that you are trying to solve a problem that does not exist. This is really true in typescript:
class A{ b=new B(); func(){ alert(this.b.member); } } class B{ member="hello there"; } var a=new A(); a.func();
As you can see, you can use class B before defining it and access your members from class A. The same thing applies to functions:
var a=()=>{ alert("function a"); b(); } var b=()=>{ alert("function b"); } a();
This should amount to a fine. Note that a can only be called after b is actually defined. This will not work:
var a=()=>{ alert("function a"); b(); } a(); var b=()=>{ alert("function b"); }
You do not need forward declarations in Typescript. Imagine that they are automatically generated for your code.
The problem becomes more complicated when you need to mix Javascript and Typescript. Since all your Typescript code is statically checked by the type compiler, pairing Javascript frameworks is not so simple.
All variables, functions, and โclassesโ added to your scope must be declared before they are used. Suppose you need jQuery for your Typescript project. All the magic of jQuery is done with the global variable "$", but even if you added a jQuery script to your html site, you cannot just reference the "$" in your Typescript code. Declaration files are used here. Adding line
at the top of your Typescript file, you tell the compiler about all the available jQuery codes..d.ts for the most commonly used Javascript frameworks can be found here: https://github.com/borisyankov/DefinitelyTyped
The last two lines are a good example of the syntax of .d.ts files:
declare var jQuery: JQueryStatic; declare var $: JQueryStatic;
Now the compiler knows that you have access to two global variables named "$" and "jQuery". Moreover, if you use VisualStudio, these declaration files will allow you to use the fantastic support for intellisense.