본문 바로가기

Errors18

[Error] Warning: You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`. 에러 발생 todomvc를 만드는데 아래와 같은 에러가 발생했다. Warning: You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`. 발생 원인 todomvc에서 해당 부분은 아래와 같은 코드로 구성되어있다. itemElement = ( {content} ); checked는 event delegation으로 해당 태그의 className이 toggle 일 때, useState로.. 2021. 10. 27.
[Typescript] Type number trivially inferred from a number literal, remove type annotation. 에러 발생 발생 원인 타입 스크립트가 추론 가능한 부분이어서, number 타입을 명시하지 않아도 된다. 코드가 길어지게 쓰지 않고 타입 스크립트의 타입 추론 기능으로 increaseId의 타입을 추론할 수 있다. 해결! 타입스크립트를 쓰는 또 한 가지 이유. 자동 타입 추론 능력이다. 2021. 10. 15.
TS2307: Cannot find module '@/App' or its corresponding type declarations. 발생 오류 발생 원인 아래 코드와 같이 webpack에서 alias를 지정했을 때, tsconfig.json에서도 path를 설정해주어야하는데 설정하지 않았을 때 에러가 발생한다. // webpack.config.js module.exports = { ... resolve: { alias: { '@': path.resolve(__dirname, '../src/'), }, ... }, }; 해결 방안 tsconfig.json에 paths를 추가해준다. // tsconfig.json "paths": { "@/*": ["src/*"] }, 2021. 10. 8.
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.
[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.