A Learning TypeScript > Interfaces 🍲 entree project.
What's up, friend?! I'm so pumped you're joining us. We've got a sick project we could totally use your help on!
See, someone's giving us amazing recommendations for songs to play. But they're not just coming in as songs. Sometimes they're an album containing a array of songs. And sometimes they're a playlist with a method that returns an array of songs.
We'd like you to write a function for us that takes in an array of those items and returns a result playlist. The result playlist should keep track of which songs appear under each artist, the in-order list of songs, and the total length of time across the playlist?
Can you do this for us, please? Friend?
If you haven't yet, set up the github.com/LearningTypeScript/projects repository locally.
git clone https://github.com/LearningTypeScript/projects learning-typescript-projects
Change your terminal directory to this project's:
In one terminal, start the TypeScript compiler in watch mode:
In another terminal, run Jest via the
For example, to run tests in watch mode:
npm test -- --watch
Your code should export an
unrollPlaylist function with an explicit return type annotation.
items: An array where each element is either a Song, Album, or Playlist
./index.test.tsfor examples of data.
Return type: an object with..
artists: Object with artist names keyed to the array of songs they're credited on
songs: An array of Songs
time: Total length of time across all songs
- Don't import code from one step into another.