[Type Error]Cannot find namespace ''.

dustn·2023년 11월 25일

type error

목록 보기
4/7




👷 에러

export type tapType = 'waiting' |'expected' |'done';

여기에서 wating이라는 string을 숨기고자 상수화를 시켜서 ctap 이라는 파일을 만들었다


ctap 파일은

export const TAB = {
  waiting: 'WAITING',
  expected: 'EXPECTED',
  done: 'DONE',
};

이런식으로 되어있다.

이렇게 선언을 해 주었으니 맨 위 type을 상수 선언한 것으로 통일되게 바꿔주어야해서

import { TAB } from "@/constant/tab/ctap";

export type tapType = TAB.waiting |TAB.expected |TAB.done;

이런식으로 import 해 와서 선언을 해 주었더니


Cannot find namespace 'TAB'

라고 경고가 뜨게 되었다... ;;




🙋 해결

export type tapType = typeof TAB.waiting |typeof TAB.expected |typeof TAB.done;

이런식으로 선언하는 타입 앞에 typeof 를 붙여주면 된다

profile
포기하지 않는 마음이 쌓여 인생을 바꾼다 📚💭

0개의 댓글