Typescript definition for constructor requires .default() call
BenGu3 opened this issue · comments
Describe the bug
According to the README, when using Typescript with this library, the import and constructor for the library is as follows:
import * as SpotifyWebApi from 'spotify-web-api-js';
let spotify = new SpotifyWebApi();
It looks like the type definitions say the constructor is the default export, so when you import as above, you actually use the constructor like this:
import * as SpotifyWebApiJs from 'spotify-web-api-js'
const spotify = new SpotifyWebApiJs.default()
To Reproduce
Steps to reproduce the behavior:
https://codesandbox.io/s/heuristic-diffie-bfzm0?file=/src/spotify.ts
Expected behavior
You should be able to have access to the types and also call the constructor without having to use a .default()
.
Additional context
It looks like this happened in v1.1.1. You can change the package version on the left side bar in the codesandbox.
I suspect it might be related with 0da9811.
I'm changing the README to use import SpotifyWebApi from 'spotify-web-api-js'
instead. Thus how projects out there using typescript are doing it.
Duplicated of #149