3

I am trying to use the "Run Build Task" command in Visual Studio Code on Windows 10 to compile TypeScript with Git Bash, but I get this error:

TypeScript error

It seems that the backslashes are being interpreted as escape characters, so they disappear.

This issue does not happen when I switch the default shell to Powershell or cmd.exe. Also, the same issue happens no matter if I install TypeScript globally (npm i -g typescript) or locally (npm i typescript). Finally, I suspect that my %PATH% environment variable may need fixing as well.

This is the tsconfig.json file I have been using:

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "sourceMap": true
  }
}

My end goal is to simply press Ctrl+S on a TypeScript code file and have it immediately transpile to JavaScript (given the TS file is valid, of course.)

1 Answer 1

1

There is an open issue in the vscode repository on GitHub about this. See link

Paths separators in build config being escaped/stripped out prior to build command being run #35593

The issue is that vscode assumes that Windows paths should be used on a Windows system. However git bash uses UNIX path seperators, which causes the issue.

The user Atomfighter10101 on GitHub suggests:

In build task change the wrong command of "command": /c/ProgramData/Anaconda3/python ${file}, to the right command of "command": /c/ProgramData/Anaconda3/python \"${file}\".

(Obviously change python to tsc for your usecase)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.