<목차>
1. typescript란?
2. typescript 기초 문법
1. typescript란?
typescript는 javascript의 슈퍼셋(상위 확장)으로 javascript에서 타입 검사가 추가된 확장 언이다.
질문사항
typescript는 javascript와 다르게 런타임 환경이 존재하지 않는다. nodejs에서 javascript로 트랜스파일 한다.
typescript -> node.js를 통한 트랜스파일 -> javascript 순으로 작동한다.
2. typescript 기초 문법
typescript는 javascript에 type검사를 추가하기 위해 만들어졌다.
문법
[예약어] [변수이름] : [타입] = [값]
// 원시타입
let num: number = 1;
let str: string = "문자열";
let bool: boolean = true;
// 참조타입
// 함수는 매개변수의 타입과 반환값의 타입을 지정해 주어야 한다.
function fn(num:number):void {}
let arr: any[] = ["문자열", 1, true];
'TypeScript' 카테고리의 다른 글
TypeScript - 타입 어설션(type assertions), 제네릭(generics) (0) | 2024.05.08 |
---|---|
TypeScript - 인터페이스(interface),타입 앨리어스(type alias) (0) | 2024.05.07 |
TypeScript - 환경세팅 (0) | 2024.04.29 |