본문 바로가기

전체 글218

interface 타입을 만들어 내는 방식 function hello1(person: { name: string; age: number }): void { console.log(`하이 ${person.name} 입니다.`); } const p1: { name: string; age: number } = { name: "Mark", age: 39, }; hello1(p1); { name: string; age: number } 얘를 조금 더 구조화 시킬 수 있지않을까? 아래처럼 사용하기! interface Person1 { name: string; age: number; } function hello1(person: Person1): void { console.log(`하이 ${person.name} 입니다.`); } co.. 2022. 2. 14.
basicType Primitive type 오브젝트 레퍼런스 형태가 아닌 실제 값을 저장하는 자료형 프리미티브 형의 내장함수를 사용 가능한 것은 자바스크립트 저리방식 덕분이다. boolean / number /string / symbol/null/undefined 6가지 이다. let name = 'mark'; name.toString(); lteral 값으로 primitive 타입의 서브타입을 나타낼 수 있음 래퍼객체로 만들수 있음 but 타입스크립트에서는 권장하지 않는다. new Bollean(false); new String('hello'); Type Casing Boolean let isDone: boolean = false; isDone = true; console.log(typeof isDone); let i.. 2022. 2. 13.
devServer proxy 설정 https://create-react-app.dev/docs/proxying-api-requests-in-development Proxying API Requests in Development | Create React App Note: this feature is available with react-scripts@0.2.3 and higher. create-react-app.dev npm install http-proxy-middleware --save //setupProxy.js const { createProxyMiddleware } = require('http-proxy-middleware'); module.exports = function (app) { app.use( '/api', creat.. 2022. 2. 6.
eject 대신 webpack설치하기 eject 대신에 사용하기 customize-cra 와 react-app-rewired 를 설치 https://github.com/timarney/react-app-rewired /* eslint-disable */ /* config-overrides.js */ const path = require('path'); module.exports = { webpack(config, env) { if (process.env.NODE_ENV === 'development') { // 개발(로컬)일 때는 기존 속성대로 리턴 return config; } // 상용일 때 (npm run build) 현재폴더 로 path 생성 config.output = { ...config.output, publicPath: set.. 2022. 2. 5.
반응형