JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API
https://jmperezperez.com/spotify-web-api-js/
MIT License
1.87k stars 265 forks source link

Typescript definition for constructor requires .default() call #166

Closed BenGu3 closed 4 years ago

BenGu3 commented 4 years ago

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.

JMPerez commented 4 years ago

I suspect it might be related with https://github.com/JMPerez/spotify-web-api-js/pull/112/commits/0da981151937e7474fc8461ec60a364107c91f2d.

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.

JMPerez commented 4 years ago

Duplicated of #149