Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- MySQL
- CSS
- 파이썬
- TiL
- 코딩테스트
- 유노코딩
- redis
- Python
- 자격증
- 프로그래머스
- 데이터베이스시스템
- 파이썬프로그래밍기초
- 항해99
- 꿀단집
- node.js
- 엘리스sw트랙
- 코드잇
- aws
- JavaScript
- HTML
- Git
- Cookie
- SQL
- nestjs
- 방송대
- 코딩테스트준비
- 방송대컴퓨터과학과
- 중간이들
- 99클럽
- 개발자취업
Archives
- Today
- Total
배꼽파지 않도록 잘 개발해요
This expression is not constructable. Type 'typeof UAParser' has no construct signatures.ts(2351) 본문
BackEnd/TypeScript
This expression is not constructable. Type 'typeof UAParser' has no construct signatures.ts(2351)
꼽파 2025. 7. 22. 23:34https://docs.uaparser.dev/intro/quick-start/using-es-modules-typescript.html
만약 named export를 default export처럼 import 하면 다음과 같은 일이 발생한다.
This expression is not constructable. Type 'typeof UAParser' has no construct signatures.ts(2351)
(alias) namespace UAParser import UAParser
- "This expression is not constructable": new UAParser()로 인스턴스를 만들 수 없다
- "Type 'typeof UAParser' has no construct signatures": UAParser 타입에 생성자가 정의되어 있지 않다
- "(alias) namespace UAParser": TypeScript가 UAParser를 네임스페이스로 인식하고 있다
Named export
import { UAParser } from 'ua-parser-js';
Default export
import UAParser from 'ua-parser-js';
결론
- ua-parser-js 라이브러리는 다음과 같이 export 되어 있음.
export class UAParser { ... } // named export
- import { UAParser }: 실제 클래스를 가져옴 → new UAParser() 가능 (O)
- import UAParser: 전체 모듈을 가져옴 → 생성자가 아닌 네임스페이스로 인식 (X)
728x90