Search code examples
typescriptcompilationvisual-studio-codetranspiler

vs code not transpiling ts files


I have Visual Studio Code (version 1.7.2) installed and typescript 1.8. I have built a simple react-native project in a folder. (The react app works just fine as I can run it in a debugger). Now I try to integrate typescript. But vs code does not transpile my code neither on save (ctrl+s) nor on build (ctrl+b). Here is my tsconfig.json file (located in the root of my project):

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",    
    "sourceMap": true,
    "noImplicitAny": true          
  },  
  "compileOnSave": true,
  "exclude": [
    "node_modules"
  ]
}

And here is the tasks.json file:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.8\\tsc",
    "isShellCommand": true,
    "args": ["-p", "."],
    "showOutput": "always",
    "problemMatcher": "$tsc"
}

Compilation occurs just fine as vs code is able to pick syntax errors from a test file calle "mytest.ts" But on save or on build there is not "mytest.js" file generated. I have followed the instructions from this https://code.visualstudio.com/Docs/languages/typescript

still I'm not able to get vs code transpile my code.

Any help, hint toward the right direction will be greatly appreciated.

Thank you in advance


Solution

  • I was finally able to solve my problem by modifying the tasks.json file like this:

        {
        ...
    
        "args": ["-p", "${workspaceRoot}"],
    
        ...
    
    }