인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

No author

This post's author information has been deleted.

[Renewal] TypeScript All-in-One: Part 2. Practical Analysis

@types/node

declare module vs declare namespace

Written on

·

399

0

declare namespace와 declare module 두 문법은 모두 외부 모듈 또는 라이브러리의 타입 정의를 선언하는 데 사용가능해서 어떤걸 써도 호환가능하며 의미 혹은 선호도에 따라 namespace를 쓸지 module를 쓸지 정하는게 맞을까여?

@types/node 에서도 각 모듈별로 declare namespace를 써도 될 것 같은데 맞을까여?

typescript

Answer 1

0

zerocho님의 프로필 이미지
zerocho
Instructor

아뇨 역할이 완전 다릅니다. declare module이 외부 라이브러리 타이핑용(타입이 없는 패키지)이고 declare namespace는 요즘 아예 쓰실 필요가 없습니다. 그냥 파일을 모듈로 만들어 import/export하면 됩니다.

No author

This post's author information has been deleted.

Ask a question