首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将visual代码语法突出显示转换为类型记录2.0 beta?

如何将visual代码语法突出显示转换为类型记录2.0 beta?
EN

Stack Overflow用户
提问于 2016-07-22 15:16:39
回答 3查看 2.8K关注 0票数 3

我做过npm install -g typescript@beta npm install -i --save-dev typescript@beta

安装了内部人员类型记录视频演播室代码。

在此之后,我从它们的类型记录2.0公告中将下面一行插入到我的项目中,vscode将其高亮显示为无效。

let foo: string | null = null;

如果这很重要,我的项目是用ng new my-project创建的。

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

代码语言:javascript
运行
复制
{
  "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

代码语言:javascript
运行
复制
{
  "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
  }
}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-07-22 16:10:49

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

摘要:

ctrl+shift+p ->类型用户设置

添加下面一行,将路径更改到TSC2.0在您的计算机上的位置。

"typescript.tsdk": "c:\\users\\mmeisberger\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"

重新启动IDE。

官方说明:

使用-较新的-打字本-版本

票数 8
EN

Stack Overflow用户

发布于 2016-07-22 23:52:01

visual studio代码语法突出显示到类型记录2.0 beta

VSCode不使用typescript来提供语法突出显示。它实际上使用的是textmate,它有几个bug:https://github.com/Microsoft/TypeScript-TmLanguage/issues

更多

alm支持2开箱即用的npm install alm -g,并实际使用TypeScript编译器提供高亮显示. 不是文字伴侣

票数 1
EN

Stack Overflow用户

发布于 2016-09-29 07:06:54

如果您使用的是Mac,您可以通过安装npm install typescript@2.0 -g类型记录2.0,以便进行全局使用。然后,键入npm list typescript -g以显示路径:

代码语言:javascript
运行
复制
$ npm list typescript -g
/usr/local/lib
└── typescript@2.0.3

您将发现命令tsctsserver应该位于path /usr/local/lib/node_modules/typescript/lib中。

现在,打开Virtual代码 (cmd + ,)的首选项,并将以下内容添加到settings.json

代码语言:javascript
运行
复制
{
  ...,
  "typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib"
}

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38530009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档