-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrated typescript typings #44
Integrated typescript typings #44
Conversation
This is the most awesome PR I have seen in a long time. Thank you so much @skovmand!! |
Thanks! And thanks for the Chuck Norris approval :-) |
@skovmand Maybe I'm being dense, but is there anyway to access these types external to the For example I'd like to store certain things in React state e.g. something like: import * as SpotifyWebApi from 'spotify-web-api-js';
interface AppState {
spotify: SpotifyWebApi.SpotifyApi;
playlist: SpotifyWebApi.PlaylistBaseObject;
} However these interfaces are not exported from this namespace, was this intentional? |
D'oh totally figured this out. It's just import * as SpotifyWebApi from 'spotify-web-api-js';
interface AppState {
spotify: SpotifyApi.ListOfUsersPlaylistsResponse;
playlist: SpotifyApi.PlaylistObjectSimplified;
} Still getting used to how Typescript does namespaces. |
Great to hear that. I was just about to investigate your problem. |
The function authorize(api: SpotifyWebApiJs.SpotifyWebApiJs): void {
const token = "...";
api.setAccessToken(token);
} @skovmand, is there anything I need to import first? |
@rshkv I am unable to use that type as well. |
Hi José.
Here's a pull request that integrates Typescript typings for both the spotify-web-api-js library and the entire spotify web api into the library.
This is a big improvement over the Typescript typings I contributed in january. The typings are updated to include all new endpoints in the Spotify Web API and adds typings for the new methods in the library. Also, by including typings in the library, the user always has the correct typings and doesn't need to browse the typings repositories (DefinitelyTyped, et.al.)
Also, the README.md is updated with an animated GIF as example as well as instructions on how to import the library in Typescript globally or as a module.
I run a project for sports music in Denmark, https://idraetsmusik.dk and use the Spotify Web Api a lot. I find the typings help me a lot during development and I would like to continue keeping them updated in this library.
I hope you can use this contribution and that you have time to review the pull request. Please send me any suggestions for modifications.
Regards,
Niels K.H. Skovmand.