简体   繁体   中英

What configuration is required to get VSCode working with TypeScript?

I am trying to get VSCode up and running with TypeScript and am having little success.

I am looking at the following:

https://code.visualstudio.com/docs/languages/typescript

It looks like once you have installed the compiler VSCode should just work but given the following:

tsconfig.json

{
  { 
  "compilerOptions": {
    "target": "es5",                          
    "module": "commonjs",                     
    "esModuleInterop": true                  
  }
}

package.json

{
  "name": "blahh",
  "version": "1.0.0",
  "description": "tryme",
  "main": "index.js",
  "author": "ghost",
  "license": "MIT",
  "devDependencies": {
    "typescript": "^3.4.5"
  }
}

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "tsc-watch",
      "command": "tsc",
      "args": ["-w", "-p", "."],
      "type":"shell",
      "isBackground": true,
      "group":"build",
      "problemMatcher": "$tslint5",
      "presentation":{
        "reveal": "always",
      }
    }
  ]
}

Project

在此处输入图片说明

HelloWorld.ts

function sayHello(name: string): void {
    console.log(`Hello ${name}!`);
}

sayHello(1);

Running the build task or tsc from the terminal correctly indicates an error until I change the 1 to a string then generates HelloWorld.js. The editor, however, is not working in that there is no intelliSense, code completion or error highlighting.

I have tried the following but this also has not worked:

VSCode TypeScript Intellisense not working

Other observations:

  1. No TypeScript version number shown in the border of the editor (as I see on the example screenshots I see)

在此处输入图片说明

  1. When adding the build task following: https://code.visualstudio.com/docs/editor/tasks#vscode there were no tsc:* templates shown.

VSCode Info

Version: 1.33.1 (user setup)
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:27:14.102Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134

Installed Extensions

Built In

TypeScript Language Basics: Enabled
... many others 

External

code --install-extension alanz.vscode-hie-server
code --install-extension alefragnani.Bookmarks
code --install-extension andyyaldoo.vscode-json
code --install-extension christian-kohler.path-intellisense
code --install-extension daiyy.quick-html-previewer
code --install-extension eamodio.gitlens
code --install-extension Edka.haskutil
code --install-extension esbenp.prettier-vscode
code --install-extension fabiospampinato.vscode-todo-plus
code --install-extension flowtype.flow-for-vscode
code --install-extension gcazaciuc.vscode-flow-ide
code --install-extension hoovercj.haskell-linter
code --install-extension jcanero.hoogle-vscode
code --install-extension justusadam.language-haskell
code --install-extension karigari.chat
code --install-extension mrmlnc.vscode-duplicate
code --install-extension ms-vscode.vscode-typescript-tslint-plugin
code --install-extension ms-vsliveshare.vsliveshare
code --install-extension ms-vsliveshare.vsliveshare-audio
code --install-extension ms-vsliveshare.vsliveshare-pack
code --install-extension phoityne.phoityne-vscode
code --install-extension SirTobi.code-clip-ring
code --install-extension WakaTime.vscode-wakatime

So what I am I missing / should I check for in my setup to enable the interactive VSCode features for TypeScript?

Check that the builtin TypeScript and JavaScript Language Features extension is enabled. To do this, search @builtin typescript the extensions view.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM