I am building a Backbone app in TypeScript and I would like to put my templates in separate .html files (for syntax etc). I don’t use Require.js now, how can I load text files then. I guess I have to write a function for that, but is there something already available in TypeScript?
Share
With the typescript compiler you can only compile Typescript files. Keeping your code in
htmlfiles won’t allow you to compile code.If you want to load code from other Typescript files, the compiler currently supports
commonjsandamdstyle imports of modules. You can tell the compiler which type of model to use by specifyingtsc --module commonjsortsc --module amd.Typescript supports two different kinds of modules, namely
externalandinternalmodules. Depending on what type of module you use, importing it works differently. Take a look at section 9 of the language specification and this or this answer.