Figma Plugin 제작을 위한 tsconfig.json 설정

2 minute read
2024-07-01

관련 링크


결론

tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "ES2022",
    "lib": ["ES2020", "DOM"],
    "skipLibCheck": true,
    "sourceMap": true,
    "outDir": "dist",
 
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
 
    "types": ["@figma/plugin-typings"]
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.test.ts", "dist"]
}


이해 아직 안되는 것

exclude 로 node_modules 에 대한 타입 체킹을 제외 했는데 왜 이부분에서 에러가 뜨는 걸까?


image-20240715204042946


일단 해결법은 skip 처리를 해줘야한다.


{
  "compilerOptions": {
    "skipLibCheck": true,
  }
}


그럼 해결된다.


exclude 설정과 skipLibCheck 설정의 차이를 GPT 에 물어보았다.


exclude VS skipLibCheck
- exclude: 컴파일러가 지정된 파일이나 디렉토리를 완전히 무시합니다. 하지만 다른 파일에서 참조되는 경우 그 참조로 인해 에러가 발생할 수 있습니다.
 
 
- skipLibCheck: 라이브러리 파일(.d.ts)의 타입 검사를 생략합니다. 이는 주로 node_modules 내의 타입 선언 파일의 에러를 무시하는 데 사용됩니다.


내가 이해하기론


exclude 는 참조하지 않은 경우 제외.


skipLibCheck 는 타입 검사를 생략