타입스크립트 관련 이슈 - boostcamp-2020/Project15-A-Client-Based-Formula-Editor GitHub Wiki
TypeScript
1. Must use destructuring props assignment
[해결 방법]
- destroyg props 할당을 사용해야합니다.
{ name, mark }: GreetingsProps
2. Missing return type on function. Warning
[해결 방법]
- React.FC 는 이슈가 있기 때문에 eslint에 설정을 추가하는 방향으로 문제 해결
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
3. Redux Action 타입 interface 보단 ReturnType으로 중복 코드 줄이기
[해결 방법]
- 기존(interface)
interface AddTodoAction {
type: typeof ADD_TODO,
payload: {
title: string
}
- 개선(type)
type AddTodoAction = ReturnType<typeof addTodo>
4. 웹팩 설정 후에도 jpg, png 파일 못찾는 문제
[해결 방법]
- @types에 다음 코드 추가
declare module '*.png' {
const src: string;
export default src;
}
declare module '*.jpg' {
const src: string;
export default src;
}