LÖVE 2D allows Effects to be added to the audio that is playing. Each effect is added with a name which can be used to obtain the audio effect later.
love.audio.setEffect("myEffect", {...});
love.audio.getEffect("myEffect");
To aid TypeScript, an EffectRegistry interface has been provided to keep track of the audio effects planned to be set.
You can re-declare this interface to tell TypeScript what effects you plan to set, this can be done in an EffectRegistry.d.ts file.
interface EffectRegistry {
myEffect: ChorusEffectSettings;
}
The example above will tell TypeScript that myEffect
is the only effect available so it will prevent you from using get/setEffect with the name of an effect not in the registry.
// No. Only effects from the registry allowed.
// Add myEffect2 to the registry or fix the name.
love.audio.setEffect("myEffect2", {...});
// myEffect2 will not exist.
love.audio.getEffect("myEffect2");
// This exists, and I also know the type of effect.
love.audio.getEffect("myEffect");
It also tells TypeScript what kind of an effect this is.