This project is read-only.

Importing text resources with require/text (language feature suggestion)

Topics: Language Specification
Mar 26, 2013 at 9:19 AM
We are loading HTML templates using require/text ( plugin. Javascript files look like this:
require(["./module", "text!./template.html"],
    function(Module, template) {
       // template available in module everywhere
Is it possible to import template this way into TypeScript module to be available in whole module? Right now it seems to me the only possible way to do this is to call require in a middle of code only:
 //some ts code
 require(["template"], (template) => doSomeStuff());
But this forces us to deal with async way of doing things where we don't want to. (BTW, we are using AMD modules).

I imagine the fitting solution could look like this in TS:
import Module = module("./module");
import template = resource("text!./template.html");
and compiler would generate require call as in first JS example (template - type any). This also may be useful to load pure JS libraries without worrying to write d.ts files.