본문 바로가기

Programming/Web

제로부터 시작하는 TypeScript VSCode 세팅_실전 웹 애플리케이션 개발 (2-1)

안녕하세요?

웹 알못.

게임 외길 인생.

비트입니다.

 

이번엔 VSC에서 TSC (라임보세요 푸하항)를 돌리는 방법에 대해 말씀드리겠습니다


1. 확장 : Code Runner 다운로드
-> ctrl + alt + n 으로 코드 실행

2. npm install -g typescript

 

2-1. test.ts 작성

function sayHello(firstName: string) {
    console.log('Hello ' + firstName)
}

let firstName: string = 'nyan'
sayHello(firstName)



3. tsc --strictNullChecks sayHello.ts


그으리고!

여기서 오류가 났습니다.

tsc : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\xxx\AppData\
Roaming\npm\tsc.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execut 
ion_Policies(https://go.microsoft.com/fwlink/?LinkID=135170)를 참조하십시 
오.
위치 줄:1 문자:1
+ tsc --strictNullChecks test.ts
+ ~~~
    + CategoryInfo          : 보안 오류: (:) [], PSSecurityException      
    + FullyQualifiedErrorId : UnauthorizedAccess


^^^ 위 오류 해결 방법 >>>

1. Visual Studio Code 관리자 권한으로 실행

2. terminal에 아래 순서대로 입력
$ Get-ExecutionPolicy (현 상태 확인)
$ Set-ExecutionPolicy RemoteSigned

 

3. 해결~


3. tsc --strictNullChecks sayHello.ts


4. test.js 생성

=> 이런 컴파일 해주는 게 Next.js 역할