Development Tip

Visual Studio Code는 어떤 TypeScript 버전을 사용하나요?

yourdevel 2020. 10. 11. 11:26
반응형

Visual Studio Code는 어떤 TypeScript 버전을 사용하나요? 어떻게 업데이트하나요?


Visual Studio Code에서 사용중인 TypeScript의 버전을 어떻게 알 수 있습니까? 특히 TypeScript 1.8.10과 VSCode 1.4.0을 사용하고있었습니다. 먼저 VSCode를 최신 버전 인 1.5.3으로 업데이트했습니다. 그러나 명령 줄에서 확인하면 TypeScript 버전이 여전히 1.8.10임을 알 수 있습니다. 그래서 명령 줄에서 TypeScript를 업데이트했는데 이제 2.0.3입니다.

Visual Studio Code가 버전 2.0.3을 사용하고 있는지 확인할 수있는 방법이 있습니까?

TypeScript를 최신 릴리스 버전으로 자동 업데이트하는 Visual Studio Code 업데이트 방법이 있습니까? 아니면 TypeScript 업데이트를 독립적으로 수행해야합니까?


에서 https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions :

VS Code는 최신 안정 버전의 TypeScript와 함께 제공됩니다.

즉, VS Code에서 사용하는 TypeScript 버전 자동으로 업그레이드 할 수있는 방법이 없습니다 . 그러나 사용자 설정이나 작업 공간 설정을 수정하여 VS Code에서 사용하는 TypeScript 버전을 재정의 할 수 있습니다.

VS Code는 어떤 TS 버전을 사용하나요?

TypeScript 파일을 열면 VS Code가 화면 오른쪽 하단의 상태 표시 줄에 TypeScript 버전을 표시해야합니다.

VS Code 상태 표시 줄 TypeScript 버전

전역 TypeScript 버전 변경

  1. 예를 들어 원하는 TypeScript 버전을 전역으로 설치하십시오. npm install -g typescript@2.0.5
  2. VS Code 사용자 설정 열기 ( F1> Open User Settings)
  3. 업데이트 / 삽입 "typescript.tsdk": "{your_global_npm_path}/typescript/lib"npm root -g를 입력하여 {your_global_npm_path}를 찾을 수 있습니다.

이제 VS Code로 여는 모든 프로젝트는이 TypeScript 버전을 사용합니다. 물론이 버전을 재정의하는 작업 공간 설정이없는 경우입니다.

로컬 TypeScript 버전 변경

  1. VS Code에서 프로젝트 열기
  2. 예를 들어 원하는 TypeScript 버전을 로컬에 설치합니다. npm install --save-dev typescript@2.0.5

    --save-dev프로젝트 package.json의을 업데이트하여 설치 한 TypeScript 버전을 devDependency.

  3. VS Code 작업 영역 설정 열기 ( F1> Open Workspace Settings)

  4. 업데이트 / 삽입 "typescript.tsdk": "./node_modules/typescript/lib"

    이제이 TypeScript 버전을 설치 한 프로젝트 만 해당 TypeScript 버전을 사용하며이 프로젝트의 VS Code에서는 전역 설치를 무시합니다.

  5. typescript.tsdk항목 을 추가 한 다음 VS Code UI를 사용하여 새 버전을 선택해야합니다.

    • VS Code 바닥 글에 표시된 버전을 클릭합니다.

      여기에 이미지 설명 입력

    • UI에서 선택하십시오.

      여기에 이미지 설명 입력

    TypeScript의 작업 공간 버전 사용을 참조하십시오.

    작업 공간 사용을보다 명확하게하기 위해 문서 개선을 참조하십시오.typescript.tsdk


Visual Studio Code에는 안정된 버전의 TypeScript가 함께 제공되지만 해당 문서에 설명 된대로 최신 버전으로 전환 할 수 있습니다.

VS Code는 최신 안정 버전의 TypeScript와 함께 제공됩니다. 최신 버전의 TypeScript를 사용하려는 경우 TypeScript tsserver.js 파일이 포함 된 디렉토리를 가리키는 typescript.tsdk 설정 ( File > Preferences > User / Workspace Settings )을 정의 할 수 있습니다 . ... 예 :

{
   "typescript.tsdk": "node_modules/typescript/lib"
}

Visual Studio Code가 버전 2.0.3을 사용하고 있는지 확인할 수있는 방법이 있습니까?

Visual Studio Code에서 TypeScript 파일을 열면 오른쪽 하단에 사용중인 TypeScript 버전이 표시됩니다.

여기에 이미지 설명 입력

TypeScript를 최신 릴리스 버전으로 자동 업데이트하는 Visual Studio Code 업데이트 방법이 있습니까? 아니면 TypeScript 업데이트를 독립적으로 수행해야합니까?

내가 한 방법은 Visual Studio Code에 TypeScript npm 모듈이 설치된 폴더를 명시 적으로 알려주는 것입니다. 저는 Windows를 사용하고 있으므로 npm 명령을 실행하여 TypeScript ( npm install -g typescript)를 설치하면 다음 폴더에 설치됩니다.

C:\Users\username\AppData\Roaming\npm\node_modules\typescript\

따라서 libTypeScript npm 설치 폴더 를 사용하도록 Visual Studio Code에 지시해야합니다. 다음을 통해이 작업을 수행합니다.

  1. VS Code 설정 열기 (파일-> 기본 설정-> 설정)

  2. typescript.tsdk설정 검색여기에 이미지 설명 입력

  3. Find where npm installed TypeScript with: npm list -g typescript. In my case, it returned C:\Users\username\AppData\Roaming\npm

  4. Override the value of typescript.tsdk setting to: C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib Note the use of double backward slashes to have a properly escaped string with backward slashes.

  5. Confirm that VS Code is using the npm version of TypeScript for intellisense by opening a TypeScript file, clicking the TypeScript version number in the bottom right and seeing in the task window that VS Code is loading TypeScript from the directory specified in step 4:

여기에 이미지 설명 입력

  1. Confirm that VS Code is using the correct version of TypeScript for compiling by going to this folder and changing the name of the file:

C:\Users\username\AppData\Roaming\npm\tsc.cmd (to something like tsc1.cmd)

Now try building in VS Code (Tasks -> Run Tasks -> tsc:build - tsconfig.json) and you should get this error message in the VS Code terminal window:

'tsc' is not recognized as an internal or external command, operable program or batch file.
The terminal process terminated with exit code: 1
  1. Change the file back to tsc.cmd and you should now be able to build and have Intellisense in VS Code for the globally installed TypeScript node package

You should see a version number listed on the bottom bar:

여기에 이미지 설명 입력

If you click on the number (2.4.0 above) you will be presented with an option to choose the version you would like to use:

여기에 이미지 설명 입력

If you don't see the version you want that means it probably isn't installed and you have to install it.

npm install -g typescript@2.7.2

Replace 2.7.2 with the version you want to install.


Though I could not find the file tsserver.js when I used Spotlight on my Mac, I tried again using mdfind, and I found its location to be "/usr/local/lib/node_modules/typescript/lib/"

So I used that path when editing my Workspace settings in settings.json

Now I am using my most recent version of TypeScript, and VSCode tells me that I am using my most recent version.


I have had a similar problem and now I succeeded in having an up-to-date version of TypeScript by modifying the environment variables on my system. In my case, we need a TypeScript version higher than 2. But I was only able to use version 1.8.3. First thing is I went to my system environment variables and checked the path variable. In there I found a reference to TypeScript version 1.8.3.

C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8.3\

When I checked the parent directory, this was also the highest version installed in that directory. I would have thought by globally installing the latest version, that I would see this here too but it is not there. The version you see here is the one that got installed with Visual Studio (not visual studio code).

So I went to Visual Studio and updated the TypeScript library to the latest version via Options > Extensions and Updates. There I searched for the latest version of TypeScript and installed it.

This made a new version available in the parent directory mentioned earlier. I then changed the path variable to:

C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\

When I now open VS Code and type tsc -v I see that I am using the latest version. No mismatch message any more, etc. Hope this helps you guys out a bit.


Typescript 패키지에는 컴파일러와 언어 서비스가 있습니다. VScode는 컴파일러가 아닌 Typescript 언어 서비스와 함께 제공됩니다. 다른 답변과 같이 오른쪽 하단에서 언어 서비스를 볼 수 있지만 어떤 컴파일러 버전이 사용되었는지는 볼 수 없습니다.

컴파일러 및 언어 서비스에 대해 서로 다른 버전을 가질 수 있습니다.

참고 URL : https://stackoverflow.com/questions/39668731/what-typescript-version-is-visual-studio-code-using-how-to-update-it

반응형