I have a typescript project working fine. I created a second project and copy some of my previous code via the file system. Everything works fine with the exception of the fact that my .js is now not in sync with my .ts.
I now how to solve the problem: removing both files and copy the again using Visual Studio interface by dragging the ts file (that will carry the .js automatically)
Anyway, I got curious and now I want to know, how is the .ts and the .js know each other?.
In ASP.NET you have the notion of code behind., but here I do not see how this done.
is Visual Studio keeping the relationship in the a hidden file?
I have a typescript project working fine. I created a second project and copy
Share
In the typescript language specification on page 75 (chapter 9.1):
There is no real association between ts and js files other than the name. A ts file is compiled to a js file and at runtime the js files are loaded. Note that the actual naming of the js files is independent of the module names and you are responsible yourself to load the scripts accordingly (e.g. using
<script>in your html page).In your case it should be fine to just copy and add a reference to the ts files. After you add the reference, be sure to change the Build Action to “TypeScriptCompile” to make sure it is passed to the typescript compiler: Select the file in solution explorer, press F4 to bring up the properties window and change the Build Action.
Update: To make the files “nested”, as mentioned in the comment, you can unload the project and add a child element to the js element, e.g. transforming
to