써치킴의 우당탕탕 개발 블로그

[TypeScript][Ch1] First Type Annotation 본문

TypeScript 합시다

[TypeScript][Ch1] First Type Annotation

써치킴 2022. 2. 5. 02:33

First Type Annotation

변수에 타입을 지정할 수 있다.(TypeScript가 가진 고유의 기능)

Ex.

Error 발생

> TypeScript에서는 변수에 값을 할당받으면 임의로 그 변수에 특정 타입을 지정해준다.

> mark는 문자열이기 때문에 변수 a는 문자열 타입으로 지정된다.

변수에 타입 지정

let a: string;

a에 string 타입을 지정한다.

function hello(b:number) {
}

b에 number 타입을 지정한다.

Comments