Rohit
Rohit

Reputation: 7161

How to Run the TypeScript build in Visual Studio code?

I am following this document to run a hello-world typescript program in Visual Studio Code Editor.

I have done following steps

  1. Installed the TypeScript compiler tsc --version shows Version 4.2.4
  2. Transpiled TypeScript into JavaScript

When i try to run the type script build, by Executing Run Build Task (⇧⌘B) I DONOT see any task to build in that.

enter image description here

So I am stuck at this point. Can some one tell me if we need to manually create this task? OR is there a pre-requisite that I am missing?

Thanks!

Upvotes: 2

Views: 1577

Answers (1)

MrCodingB
MrCodingB

Reputation: 2314

Try restarting VSCode. If that doesn't work try configuring the task via:

Command palette (Ctrl+Shift+P / F1) > Tasks: Configure default build task

If that doesn't work here are the default task configurations:

{
    "version": "2.0.0",
    "tasks": [
        {  // For build
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "problemMatcher": [
                "$tsc"
            ],
            "group": "build",
            "label": "tsc: build - tsconfig.json"
        },
        {  // For watch
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "option": "watch",
            "problemMatcher": [
                "$tsc-watch"
            ],
            "group": "build",
            "label": "tsc: watch - tsconfig.json"
        },
        { // If both of the above don't work you could create an npm script and run it via this task
            "type": "npm",
            "script": "build", // This should be the name of your script
            "problemMatcher": [],
            "label": "npm: build typescript"
        }
    ]
}

For these to be detected create a .vscode Folder at the root of your workspace and create a file tasks.json in it. If you put the above json in it, VSCode will find your tasks.

Upvotes: 3

Related Questions