error-report.md•4 kB
# Google Sheets MCP Server - Build Error Report
## 빌드 실행 결과
- **명령어**: `npm run build`
- **실행 시간**: 2025년 10월 15일
- **결과**: 실패 (Exit code: 2)
- **총 에러 개수**: 5개
## 에러 분석 및 해결 방안
### 1. 네임스페이스 및 모듈 에러
#### 에러 1: `src/auth/auth-service.ts` - `google` 네임스페이스 없음
```
error TS2503: Cannot find namespace 'google'.
```
**원인**:
- `import { google } from 'googleapis';`로 가져온 `google` 객체를 TypeScript가 네임스페이스로 인식하지 못하고 있습니다.
- `tsconfig.json`의 `module` 또는 `moduleResolution` 설정과 `googleapis` 라이브러리의 타입 선언 방식 간의 충돌일 수 있습니다.
**해결 방안**:
```typescript
// src/auth/auth-service.ts 상단
import { google, Auth } from 'googleapis';
// new google.auth.OAuth2(...) 부분을 아래와 같이 수정
new Auth.OAuth2Client(...)
```
#### 에러 2: `src/index.ts` - `tool.handler` 타입이 `unknown`
```
error TS18046: 'tool.handler' is of type 'unknown'.
```
**원인**:
- `createTools` 함수가 반환하는 `tools` 배열의 `handler` 속성에 대한 타입이 명확하게 정의되지 않아 `unknown`으로 추론되었습니다.
- `unknown` 타입의 값은 직접 호출할 수 없으므로 에러가 발생합니다.
**해결 방안**:
- `src/tools/index.ts`에서 Tool 타입을 정의할 때 `handler`의 타입을 명시적인 함수 타입으로 지정해야 합니다.
```typescript
// src/tools/index.ts
interface Tool {
name: string;
// ... other properties
handler: (args: any) => Promise<any>; // any 대신 더 구체적인 타입 사용 권장
}
```
### 2. 타입 정의 불일치 에러 (Type Definition Mismatch)
#### 에러 3: `src/services/google-sheets-service.ts` - `SpreadsheetFile` 타입 불일치
```
Type '{... webViewLink: string | null | undefined; owners: string[] | undefined; }[]' is not assignable to type 'SpreadsheetFile[]'.
...
Type 'undefined' is not assignable to type 'string | null'.
```
**원인**:
- (기존 에러 2와 동일) `exactOptionalPropertyTypes: true` 설정으로 인해, Google Drive API가 반환할 수 있는 `undefined` 값을 `SpreadsheetFile` 타입의 `webViewLink` 속성이 허용하지 않습니다.
**해결 방안**:
- `src/types/index.ts`의 `SpreadsheetFile` 인터페이스를 수정하여 `undefined`를 허용해야 합니다.
```typescript
// src/types/index.ts
export interface SpreadsheetFile {
// ...
webViewLink?: string | null; // ?를 추가하여 undefined 허용
owners?: string[]; // ?를 추가하여 undefined 허용
}
```
#### 에러 4: `src/services/google-sheets-service.ts` - `SheetInfo` 타입 불일치
```
...
Types of property 'gridProperties' are incompatible.
...
Type 'number | null' is not assignable to type 'number'.
```
**원인**:
- (기존 에러 3, 18-25와 관련) Google API가 반환하는 `gridProperties`의 `rowCount`는 `number | null` 타입이지만, 우리가 정의한 `SheetInfo` 타입에서는 `rowCount`를 `number`로 단정하고 있어 `null` 값을 할당할 수 없습니다.
**해결 방안**:
- `src/types/index.ts`의 `SheetInfo` 인터페이스를 수정하여 `null` 값을 허용해야 합니다.
```typescript
// src/types/index.ts
export interface SheetInfo {
// ...
gridProperties?: {
rowCount: number | null; // null 허용
columnCount: number | null; // columnCount도 동일하게 수정
};
}
```
## 우선순위별 수정 권장사항
1. **타입 정의 수정**: `SheetInfo`와 `SpreadsheetFile`의 타입 정의를 API 응답에 맞게 수정하는 것이 가장 시급합니다. (에러 3, 4)
2. **네임스페이스 문제 해결**: `google` 네임스페이스 에러를 해결해야 `auth-service` 관련 코드가 정상적으로 컴파일됩니다. (에러 1)
3. **핸들러 타입 지정**: `tool.handler`의 타입을 명시하여 `index.ts`의 에러를 해결합니다. (에러 2)