TypeScript
-
[TypeScript] 인터페이스TypeScript 2022. 9. 8. 22:56
소개 TypeScript에서, 인터페이스는 이런 타입들의 이름을 짓는 역할을 하고 코드 안의 계약을 정의하는 것뿐만 아니라 프로젝트 외부에서 사용하는 코드의 계약을 정의하는 강력한 방법입니다. 첫 번째 인터페이스 (Our First Interface) function printLabel(labeledObj: { label: string }) { console.log(labeledObj.label); } let myObj = {size: 10, label: "Size 10 Object"}; printLabel(myObj); 타입 검사는 printLabel 호출을 확인합니다. printLabel 함수는 string 타입 label을 갖는 객체를 하나의 매개변수로 가집니다. 이 객체가 실제로는 더 많은 프로퍼..
-
[TypeScript] 기본 타입TypeScript 2022. 9. 7. 21:43
소개(Introduction) TypeScript는 JavaScript와 거의 동일한 데이터 타입을 지원하며, 열거 타입을 사용하여 더 편리하게 사용할 수 있습니다. javascript에서는 열거 타입을 지원하지 않습니다. 형태 대부분의 형태는 아래와 같습니다. let 변수명: 타입 = 값; 1) 불리언(Boolean) 참/거짓(true/false)를 나타내는 값입니다. let isTrue: boolean = false; 2) 숫자(Number) JavaScript처럼 TypeScript의 모든 숫자는 부동 소수 값입니다. TypeScript는 2, 8, 10, 16진수 리터럴을 지원합니다. let decimal: number = 6; let hex: number = 0xf00d; let binary: ..