Why does command "tsc file.ts" give no output and not produce a js file?

时间:2015-09-29 00:51:49

标签: makefile typescript mint

I have just started work on a project with some typescript code, and I'm trying to compile the .ts files to .js files from within Linux Mint, but it's not working as I'd expect.

There is a Makefile, but it's not working. Running make returns an error:

tsc --noImplicitAny --noEmitOnError --out client/welcome.js client/welcome.ts
make: *** [client/welcome.js] Error 1

I have also tried creating an example typescript file greeter.ts (as per this official tutorial) containing:

function greeter(person) {
    return "Hello, " + person;
}
var user = "Jane User";
document.body.innerHTML = greeter(user);

and tried compiling the ts file to javascript with the command (as per the same tutorial) tsc greeter.ts however the command completes with no output, and no .js file has been created.

I haven't previously worked with typescript at all, and though I've used Makefile's before I don't know much about them either, so I'm hoping it's something really obvious!

2 个答案:

答案 0 :(得分:7)

我遇到此问题是因为我的ID中包含以下行:

func convertToUTC(dateToConvert:String) -> String {
      let formatter = DateFormatter()
      formatter.dateFormat = "EEE MMM d yyyy HH:mm:ss.SSS'Z"

      let convertedDate = formatter.date(from: dateToConvert)
      formatter.timeZone = TimeZone(identifier: "UTC")
      return formatter.string(from: convertedDate!)
         }

requred date form is Sat Aug 1 2020 23:38:56 GMT+0530

删除后可以正常工作。

答案 1 :(得分:3)

  

- noEmitOnError

这意味着如果检测到错误将不会生成js 。我强烈建议不要使用此选项(更改Initial sortorder for Primeface datatable with multisort的主要好处)

更多

检查您的as!版本。您提供的代码适用于#include <stdio.h> unsigned int hash(unsigned int x) { x = ((x >> 16) ^ x) * 0x45d9f3b; x = ((x >> 16) ^ x) * 0x45d9f3b; x = ((x >> 16) ^ x); return x; } int compareArrays(int *arr1, int *arr2, int size) { if (size == 0) return 1; unsigned long sum1 = 0; unsigned long sum2 = 0; for (int i = 0; i < size; ++i) { sum1 += hash(arr1[i]); } for (int i = 0; i < size; ++i) sum2 += hash(arr2[i]) ; return sum1 == sum2; } int main(void) { int a[] = {1,2,3,4,5,6,7,8,255}; int b[] = {1,2,3,4,5,6,7,8,9}; int size = 9; printf("Are they the same? %s.\n", compareArrays(a, b, size) ? "yes" : "no"); return 0; }

why typescript

更新

tsc命令至少应该起作用。见下文:

enter image description here