Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Compressor to work with TypeScript

I want Django Compressor to work with Microsoft new language TypeScript.

I downloaded the compiler tsc and it works fine.

When trying to use it with Django Compressor this way:

COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
    ('text/typescript', 'tsc {infile} {outfile}'),
    )

and

{% compress js %}
        <script type="text/typescript" charset="utf-8">
            var x=3;
            function greeter(person: string) {
            return "Hello, " + person;
            }

            var user = "Jane User";
        </script>
{% endcompress %}

the output is an empty JS script tag

<script type="text/javascript"></script>

I guess it is because the tsc program does not have the option to write the code to a predefined file.

Does someone have an idea?

(As said, the tsc works as well as django compressor for LESS..)

like image 470
YardenST Avatar asked Oct 07 '22 08:10

YardenST


1 Answers

tsc file1.ts file2.ts compiles file1.ts and file2.ts into file1.js and file2.js, respectively.

> tsc.exe
Syntax:   tsc [options] [file ..]

Examples: tsc hello.ts
      tsc --out foo.js foo.ts
      tsc @args.txt

Seems like you want to run tsc {infile} --out {outfile}

like image 64
Ryan Cavanaugh Avatar answered Oct 10 '22 02:10

Ryan Cavanaugh