The template looks like this [^ 1]
{% load compress %}
{% compress js %}
<script type="text/typescript">
class Greeter {
constructor(public greeting: string) { }
greet() {
return "<h1>" + this.greeting + "</h1>";
}
};
var greeter = new Greeter("Hello, world!");
var str = greeter.greet();
document.body.innerHTML = str;
</script>
{% endcompress %}
settings.py
COMPRESS_PRECOMPILED = ('text/typescript', 'tsc --out {outfile} {infile}')
I get an error
error TS6053: File '/tmp/tmpxxt3rmzl.ts' not found.
tsc can only use .ts
or .d.ts
extensions. [^ 2]
Create a script that wraps tsc and specify it.
settings.py
COMPRESS_PRECOMPILED = ('text/typescript', '/path/to/my-tsc {infile} {outfile}')
my-tsc
#!/bin/sh
cp $1 $1.ts
tsc $1 --out $2
rm $1.ts
[^ 1]: TypeScript code is Official Samples
Recommended Posts