본문 바로가기

Javascript/Typescript11

Vercel Dev api 등록시 에러 해결 tsconfig.json:10:25 - error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext' tsconfig.json:11:5 - error TS5023: Unknown compiler option 'allowImportingTsExtensions'. Vercel로 serverless 함수를 만들어서 실행을 해보니 위와 같은 에러가 발생했다. 알고보니 tsconfig.json의 TS버전과 Vercel의 TS 버전이 맞지 않아 생기는 문제이다. 버전을 맞춰주면 해결된다. package.json에 아래와 같이 작성해주면 된다. overrides옵선은 node16 npm 8버전 .. 2023. 12. 1.
VITE 환경에서 .env 사용법 REACT에서 CRA를 사용하는 방법과 별개로 vite를 사용하여 프로젝트를 구성하는 방법이 있듯 VUE프로젝트 역시 vite로 구성할 수 있다. 하지만 vite 환경변수를 사용함에 있어서는 VUE와 REACT 모두 기존의 환경 변수 사용법이 아니라 vite의 환경변수 사용법을 따라야 한다. 환경 변수명은 REACT의 경우 REACT_APP_* 으로 VUE의 경우 VUE_APP_* 으로 짓고 사용할 땐 process.env로 사용하라고 공식문서에 적혀있는데 vite를 사용할 해서 프로젝트를 구성한 프로젝트라면 위의 방식대로 해서는 안되다는 것이다. 로마에 가면 로마의 법을 따라듯 vite 환경에서는 vite만의 규칙이 있다. vite의 경우 환경변수명은 VITE_*로 사용할 때는 import.meta.e.. 2023. 12. 1.
[Typescript] Generic - 1 function toObj(a: string, b: string): { a: string; b: string }; function toObj(a: number, b: number): { a: number; b: number }; function toObj(a: boolean, b: boolean): { a: boolean; b: boolean }; function toObj( a: string | number | boolean, b: string | number | boolean ): { a: string | number | boolean; b: string | number | boolean } { return { a, b }; } toObj("A", "B"); toObj(1, 2); toObj(true.. 2023. 11. 18.
[Typescript] abstract class interface를 implements하는 것과 abstract class를 extends하는 것의 차이점 interface Creator { sound: string; color: string; speak(): string; getColor(): string; } class Cat implements Creator { constructor(public sound: string, public color: string) {} speak() { return this.sound; } getColor() { return this.sound; } } abstract class Creator { abstract color: string; abstract getColor(): string; constructor(pu.. 2023. 11. 13.