如何将visual studio代码语法高亮显示切换到typescript 2.0 beta?

如何将visual studio代码语法高亮显示切换到typescript 2.0 beta?,typescript,visual-studio-code,Typescript,Visual Studio Code,我做完了 npm安装-gtypescript@beta npm安装-i--save devtypescript@beta 安装了insiders typescript visual studio代码 在此之后,我从TypeScript2.0公告中将以下行插入到我的项目中,vscode将其突出显示为无效 让foo:string | null=null 如果重要的话,我的项目是用ng new my project创建的 这里还有我的project.json文件和tslint.json文件 { "

我做完了
npm安装-gtypescript@beta
npm安装-i--save devtypescript@beta

安装了insiders typescript visual studio代码

在此之后,我从TypeScript2.0公告中将以下行插入到我的项目中,vscode将其突出显示为无效

让foo:string | null=null

如果重要的话,我的项目是用
ng new my project
创建的

这里还有我的project.json文件和tslint.json文件

{
  "name": "portal-app",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "postinstall": "typings install",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.3",
    "@angular/compiler": "2.0.0-rc.3",
    "@angular/core": "2.0.0-rc.3",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.3",
    "@angular/platform-browser": "2.0.0-rc.3",
    "@angular/platform-browser-dynamic": "2.0.0-rc.3",
    "@angular/router": "3.0.0-alpha.8",
    "es6-shim": "0.35.1",
    "ng2-bootstrap": "^1.0.20",
    "reflect-metadata": "0.1.3",
    "rx-socket-subject": "^0.7.0",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.26",
    "zone.js": "0.6.12"
  },
  "devDependencies": {
    "angular-cli": "1.0.0-beta.9",
    "codelyzer": "0.0.20",
    "ember-cli-inject-live-reload": "1.4.0",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "protractor": "3.3.0",
    "ts-node": "0.5.5",
    "tslint": "3.11.0",
    "typescript": "^2.0.0",
    "typings": "0.8.1"
  }
}
tslint.json

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
    "eofline": true,
    "forin": true,
    "indent": [
      true,
      "spaces"
    ],
    "label-position": true,
    "label-undefined": true,
    "max-line-length": [
      true,
      140
    ],
    "member-access": false,
    "member-ordering": [
      true,
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-key": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-eval": true,
    "no-inferrable-types": true,
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": true,
    "no-unused-expression": true,
    "no-unused-variable": true,
    "no-unreachable": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "object-literal-sort-keys": false,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "quotemark": [
      true,
      "single"
    ],
    "radix": true,
    "semicolon": [
      "always"
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],

    "directive-selector-name": [true, "camelCase"],
    "component-selector-name": [true, "kebab-case"],
    "directive-selector-type": [true, "attribute"],
    "component-selector-type": [true, "element"],
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "component-class-suffix": true,
    "directive-class-suffix": true
  }
}

我找到了一个有方向的地方(下面的链接)

摘要:
ctrl+shift+p->键入用户设置

添加以下行,更改tsc 2.0在您的计算机上的所在位置的路径

“typescript.tsdk”:“c:\\users\\mmeisberger\\AppData\\Roaming\\npm\\node\u modules\\typescript\\lib”

重新启动IDE

此处的官方说明:

visual studio代码语法突出显示到typescript 2.0测试版

VSCode不使用
typescript
来提供其语法突出显示。它实际上使用了
textmate
,其中有一些错误:

更多
alm支持ts 2开箱即用
npm安装alm-g
,并实际使用TypeScript编译器提供高亮显示 如果您使用的是Mac,您可以通过
npm安装typescript 2.0typescript@2.0-g
用于全球使用。然后,键入
npm list typescript-g
以显示路径:

$ npm list typescript -g
/usr/local/lib
└── typescript@2.0.3
您会发现命令
tsc
tsserver
应该位于路径
/usr/local/lib/node\u modules/typescript/lib

现在,打开virtualstudio Codecmd+,)的首选项,并将以下内容添加到settings.json

{
  ...,
  "typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib"
}

重新启动虚拟演播室代码,并打开一个TypeScript文件,现在它应该突出显示TS代码为2.x

您是建议我在那里提问还是建议答案在那里。如果是后者,我已经遵循了该指南,我会假设答案就在那里。我找不到答案。如果您使用angular cli,并且希望使用typescript 2.0,则需要让编译器使用它。目前我唯一能找到的方法是将cp node_modules/typescript转换为node_modules/angular cli/node_modules。这对语法突出显示没有影响在进行更改后是否重新启动了ide?您确定文件夹存在的路径正确吗。另外,如果您打开terminal并导航到typescript文件夹,执行类似于./tsc--version的操作,并确保它是2.0?有趣的。我一定要试试阿尔姆