본문 바로가기

전체 글

(117)
# 2-5 TypeScript - BlockChain TypeScript는 import 과정이 다르다. import * as CryptoJS from "crypto-js"; Hash를 사용하기 위해서 crypto-js를 설치한다. class 안에서 method 접근 생성자에 따라서 Class 내 Block 생성 후 method에 접근여부가 달라진다. static을 지정하면 접근가능하다. // 예를 들면 sayHello = () => {return "Hello"}; //Block을 생성하지 않고는 sayHello에 접근할 수 없다. //Block.sayHello //Block을 생성하지 않고 접근하려면 아래와 같이 생성한다. static sayHello2 = ():string => {return "Hello"}; //접근 가능하다. Block.sayHello2
# 2-4 TypeScript - class interface는 js로 컴파일 되지 않는다. interface 대신에 class를 쓴다. class Human { public name: string; public age: number; public gender: string; constructor(name: stiring, age: number, gender: string) { this.name = string; this.age = number; this.gender = string; } } const daniel = new Human("Daniel", 30, "male"); const sayHi = (person): string => { return `Hello ${person.name}, you are ${person.age}, you are ..
# 2-3 TypeScript - 파라미터에 Object 넘기기 interface Human { name: string; age: number; gender: string; } const person = { name: "Seunghwan"; age: 30; gender: gender: "male"; } const sayHi = (person): string => { return `Hello ${person.name}, you are ${person.age}, you are a ${person.gender}!`; }; console.log(sayHi(person)); export {}; github.com/hwan02/typescript
# 2-2 TypeScript 특징 및 컴파일 위치 및 타입스크립트 설정 const sayHi = {name: string, age: number, gender: string}:string => { return `Hello ${name}, you are ${age}. you are a ${gender}`; }; sayHi("Seunghwan", 30, "male"); export {}; 타입스크립트에서는 파라미터 변수의 데이터 타입을 명시할 수 있다. 파라미터 옆 : string을 통해서 return값을 설정할 수 있다. tsc-watch를 통해 새로고침시 변경된 적용을 불러오게 한다. yarn add tsc-watch --dev include를 src/**/*로 하면 typescript는 src안으로 가게 되고 컴파일 된 내용은 outDir에 설정한 dist 로 들어가게 된다.
# 2-1 TypeScript - 특징 및 규칙 Typed 언어 어떤 종류의 변수와 데이터인지 설정을 해줘야 한다. 예) 문자열(String)만 들어갈거로 설정 export {}; 파일이 모듈이 된다는 걸 이해할 수 있도록 한다. 없다면 선언 오류가 난다. 파라미터에 세개를 입력해야 하는데 두개를 입력하면 한개가 없다면 알려주고 컴파일도 되지 않는다. 파라미터 뒤에 ? 를 쓰면 Optional 이라는 의미 github.com/hwan02/typescript
# 2-0 TypeScript - config setting 환경설정 TypeScript은 javascript의 superset이다. 프로그래밍 언어 컴파일하면 자바스크립트로 컴파일 된다. 자바스크립트 위에 있다. 왜 사용하는가? 1. 엄격한 규칙 2. 큰 프로젝트, 팀에서 일하거나 버그를 최소화 한다. 3. 예측가능 4. 읽기 쉬운 코드 yarn global add typescript tsconfig.json 파일은 typescript에게 어떻게 javascript로 변환하는지 알려준다. 1.compilerOptions node.js 다양한 걸 import export 어떤 버전의 자바스크립트 sourcemap 처리 2.include 어떤 파일들이 컴파일 과정에 포함되는지 파일의 배열을 적으면 된다. 예) index.ts 3.exclude 예) node_modules 명..
# 1 준비단계 Uber Eats 프로젝트 프로그램 설명 경로 시작날짜 종료날짜 백엔드 TypeScript nest.js 이해하기 위해 필요 nomadcoders.co/typescript-for-beginners 20210210 20210211 Nest.js nomadcoders.co/nestjs-fundamentals 20210212 20210214 프론트엔드 TypeScript React Especially Hooks nomadcoders.co/react-hooks-introduction 20210215 20210302 데이터전달 GraphQL 백엔드와 프론트엔드 간 소통 nomadcoders.co/graphql-for-beginners nomadcoders.co/react-graphql-for-beginners 2..
자바스크립트 클로저 클로저는 독립적인 (자유) 변수를 가리키는 함수이다. 또는, 클로저 안에 정의된 함수는 만들어진 환경을 ‘기억한다’. 일반적으로 함수 내에서 함수를 정의하고 사용하면 클로저라고 한다. function getClosure() { var text = 'variable 1'; return function() { return text; }; } var closure = getClosure(); console.log(closure()); // 'variable 1' 위에서 정의한 getClosure()는 함수를 반환한다. 반환된 함수는 getClosure() 내부에서 선언된 변수 text를 참조하고 있다. 참조된 변수는 함수 실행이 끝났다고 해서 사라지지 않고, variable 1을 반환하고 있다. getClos..