2016-07-22 1 views
3

나는 npm install -g [email protected] npm install -i --save-dev [email protected]Visual Studio 코드 구문 강조 표시를 typescript 2.0 베타로 전환하는 방법은 무엇입니까?

이 관계자는 비주얼 스튜디오 코드를 타이프 ​​라이터 설치 완료했습니다.

그런 다음 typescript 2.0 발표에서 내 프로젝트에 다음 줄을 삽입하고 vscode가 유효하지 않은 것으로 강조 표시합니다. 이 중요하다면

let 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 
    } 
} 
+0

https://blogs.msdn.microsoft.com/typescript/2016/07/11/announcing-typescript-2-0-beta/ – Danieboy

+0

내가 물어 보거나 거기에 답변을 제안하는 것이 좋습니다. 나중에, 그 가이드를 이미 따라 갔다면 – matthewdaniel

+0

나는 대답이 있다고 가정합니다. – Danieboy

답변

8

I (아래 링크) 방향이있는 장소를 발견한다.

요약 :
Ctrl + Shift + P -> 유형의 사용자 설정

는 경로를 변경 다음 줄을 추가 할 경우 TSC 컴퓨터에 2.0 살고있다.

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

는 IDE를 다시 시작

. 여기

공식 지침 :
https://code.visualstudio.com/Docs/languages/typescript#_using-newer-typescript-versions

+0

angular-cli를 사용하고 있고 typescript 2.0을 원한다면 컴파일러를 사용해야합니다. 현재 내가 할 수있는 유일한 방법은 node_modules/angular-cli/node_modules에 cp node_modules/typescript입니다. – matthewdaniel

+0

변경 후 IDE를 다시 시작한 적이 있습니까? – basarat

+0

변경 사항을 적용한 IDE를 다시 시작 했습니까? 폴더가 존재하는 올바른 경로를 가지고 있는지 확실합니까? 또한 터미널을 열고 typescript 폴더로 이동하여 ./tsc --version과 같은 작업을하고 2.0인지 확인하십시오. – matthewdaniel

1

비주얼 스튜디오 코드 구문은 2.0 베타

VSCode은 구문 강조를 제공하기 위해 typescript를 사용하지 않습니다를 타이프하는 강조. https://github.com/Microsoft/TypeScript-TmLanguage/issues

ALM 박스 npm install alm -g에서 TS 2를 지원하며, 실제로 강조를 제공하기 위해 타이프 스크립트 컴파일러를 사용하여 ... Not Text Mate

+0

흥미 롭습니다. alm 한 번 해봐야 겠어. – matthewdaniel

0

경우 : 그것은 실제로 버그가있는 textmate를 사용 Mac을 사용하는 경우 typescript 2.0npm install [email protected] -g까지 사용할 수 있습니다.

$ npm list typescript -g 
/usr/local/lib 
└── [email protected] 

을 그리고 당신은 명령 tsc를 찾을 수 및 tsserver 경로 /usr/local/lib/node_modules/typescript/lib에 있어야합니다 : 그런 다음 경로를 보여 npm list typescript -g을 입력합니다.이제

가상 스튜디오 코드 ( cmd + ,)의 환경 설정을 열고 추가하여 settings.json

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

다시 시작 가상 스튜디오 코드에 다음과 타이프 스크립트 파일을 열고, 지금은 강조한다 TS 코드는 2.x입니다.

관련 문제