types.ts파일 안에 모든 type들을 다 정의해 놓는 중이었다.
// Block
export interface IMatrix {
...
moveBlock(matrix: MatrixState, block: IBlock): void;
}
export interface IBlock {
...
new (options: BlockOption): IBlock;
updateColor(matrix: MatrixState, $matrix: IMatrix, color: number): void
근데 IMatrix 의 moveBlock에서 IBlock쪽에 다음과 같은 에러가 나왔다.
'IBlock' was used before it was defined.
그래서 막 찾아본 결과 다음과 같은 2가지 방법을 알아냈다.
파일 맨 위에 적기
/* eslint-disable no-use-before-define */
export namespace Tetris {
export type Shape = Array<Array<number>>
...
나쁘지는 않은데,, 아래 방법이 더 깔끔하다고 생각한다.
.eslintrc.js 파일 수정
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'airbnb-base',
...
],
rules: {
...
},
overrides: [
{
files: ['src/types.ts'],
rules: {
'no-use-before-define': ['off'],
},
},
],
};
overrides 해주면 된다.
