TypeScript-component, hook npm에 배포하기 최근 반응형 pagination component와 hook을 작성했다. 이 둘을 npm에 배포해놓고 싶었다.(최근 package관련해서 경각심을 느끼게된 계기도 있고해서,, 겸사겸사) npm에 배포하기 전 해야할 것 먼저 npm계정이 있어야한다. npm login으로 로그인해야한다. package.json 에 배포관련 스크립트, 정보를 추가해야한다. tsconfig.json 에 빌드관련 정보를 추가해야한다. package.json { "name":"배포할 패키지 명을 작성한다.", "main":"dist/index.js", "types":"dist/index.d.ts", "version":"0.0.1" //시맨틱버저닝을 따른다, "des..
문제 Jest 테스트시 cypress의 test scripts를 실행 Jest 테스트파일에서 import한 파일들이 절대경로로 import하는 또 다른 파일들을 읽을 수 없어 cannot find module 이슈가 발생 //jest.test.ts import { add } from "../utils/func"; // accept //utils/func.ts import { type } from "components/Navbar"; //cannot find module 원인 jest.config.js 설정에 cypress를 제외하는 설정이 없음 절대경로 설정이 없었음 해결 //jest.config.js { //...other options testPathIgnorePatterns: [ "/node_mod..
Styled-Components With TS(theme, globalStyle) TypeScript TS에 Styled-Components를 적용해보자 설치 npm install @types/styled-components 1. 테마 공통적으로 사용되는 스타일을 테마로 묶어서 코드일관성을 지킬 수 있도록 한다. 이를 위해 먼저 타입선언과 테마를 작성해야한다. 1.1 styled.d.ts: 타입선언파일, 테마작성하기 .d.ts를 타입선언파일이라고 한다. TS코드의 타입 추론을 돕는 파일이다. 첫번째 단계는 styled.d.ts 라는 테마에 사용될 변수들의 타입들을 선언하는 파일을 만드는 것이다. styled.d.ts 만들기 import 'styled-components'; // and ex..
- Total
- Today
- Yesterday