Attempting to use typescript definitions for Apple MusicKitJS in Ionic 5

Hey everyone,

I’m attempting to use Apple’s MusicKitJS framework inside of my Ionic 5 project with Angular. Originally, I attempted to reference the framework from a script tag inside of my index.html file, but I soon realized that Angular can not interact with these (or at least for this instance). Then, I proceeded to find an npm package containing all the TS definitions for Apple’s MusicKitJS:

Now, I can’t figure out how to use these definitions with my project after following the instructions. This is the import code I have on a page, and I can’t seem to get it to find the package:

import { MusicKit } from 'musickit-typescript';

If anybody can help me figure out what I’m doing wrong here, it would be very much appreciated.

Thank you!

Did you follow the bit in the installation instructions requiring you to modify tsconfig.json?

Yes I did. It didn’t seem to make any difference…

@rapropos if it helps, this is the error I get when I attempt to reference it and run ionic serve:

ERROR in src/app/therapy/,26): error TS2306: File '(mypathtomyproject)/node_modules/musickit-typescript/MusicKit/index.d.ts' is not a module.