본문 바로가기

전체 글119

TS7016: Could not find a declaration file for module '@/App'. '/src/App.jsx' implicitly has an 'any' type. 발생 오류 발생 원인 타입스크립트는 .js 확장자를 허용하지 않는다. 따라서 js에서 ts로의 부분적인 마이그레이션을 진행할 때는 다음과 같은 오류가 발생할 수 있다. 해결 방안 tsconfig.json에서 allowJS 옵션을 설정해서 js 파일 사용을 허용할 수 있다. // tsconfig.json "allowJS" : true 2021. 10. 8.
[Typescript] TS2339: Property 'gameState' does not exist on type 'Readonly<{}>'. javascript에서 typescript로 마이그레이션 중 다음 에러가 발생했다. 문제의 코드는 아래와 같다. import React from "react"; export class GameStateBar extends React.Component { constructor(props: any) { super(props); this.state = { gameState: "" }; } handleGameStateChange(e: any) { this.setState({ gameState: e.detail }); } handleRestart(e: any) { this.setState({ gameState: "" }); } componentDidMount() { window.addEventListener("g.. 2021. 10. 7.
Partial migration of javascript to typescript 다음 글은 Microsoft/TypeScript-React-Conversion-Guide의 예제를 기반으로 작성되었습니다. 본문의 코드는 다음 링크에 있습니다. 본 글은 Javascript에서 Typescript로의 부분적인 전환을 위한 TicTacToc을 예제로 한 가이드이다. 부분적인 전환이 아닌, 새로운 프로젝트를 시작하는 것이라면 다음 링크를 참고하자. 모든 프로젝트에서 Typescript를 채택하는 것은 2단계로 나눌 수 있다. 빌드 파이프라인에 TypeScript 컴파일러(tsc)를 추가 JavaScript 파일을 TypeScript 파일로 변환 프로젝트 전환 전에는 다음과 같은 폴더 구조를 가지고 있다. TicTacToe_JS / |---- css/ // css style sheets |--.. 2021. 10. 7.
[Typescript] TypeError: loaderContext.getOptions is not a function jsx를 tsx로 마이그레이션 하기 위해 ts-loader와 Webpack을 설정했다. (repo-url) npx webpack Webpack을 실행하자 다음과 같은 에러가 났다. TicTacToe_TS_hochan % npx webpack Hash: a8dde2af1ae05d91a224 Version: webpack 4.46.0 Time: 274ms Built at: 2021. 10. 07. 오후 2:44:28 2 assets Entrypoint main = ./bundle.js ./bundle.js.map [0] ./src/app.jsx 403 bytes {0} [built] [failed] [1 error] WARNING in configuration The 'mode' option has not .. 2021. 10. 7.
git config 설정하기 VSCode에서 id/pw 설정을 자동 저장하고 싶으면 아래 명령어를 입력하자. git config --global credential.helper store https://git-scm.com/docs/git-credential-store 이미 정보가 있다면 아래 명령어로 삭제해주자. git config --unset user.name git config --unset user.email 아래는 전역 설정을 지워주는 명령어. git config --unset --global user.name git config --unset --global user.email 현재 git config를 아래 명령어로 확인할 수 있다. git config --list 아래 명령어로 추가해보자. git config use.. 2021. 10. 1.
SOLID와 MVC 설계단계에서 어떤 아키텍처를 선택하여 설계를 진행할 것인지는 결국엔 프로그램의 전체적인 방향성, 비용과 시간에 직결된 문제이다. Robert C. Martin은 다섯 가지 지침을 개발했다. 다섯 가지 지침과 원칙을 통해 개발자는 읽기 쉽고 유지 보수가 쉬운 프로그램을 쉽게 만들 수 있다. 다섯 가지 원칙은 S.O.L.I.D이다. S: Single Responsibility Principle (단일 책임원칙) O: Open-Closed Principle (열린-닫힌 원칙) L: Liskov Substitution Principle (리스 코프 치환 원칙) I: Interface Segregation Principle (인터페이스 분리 원칙) D: Dependency Inversion Principle (의.. 2021. 9. 1.