Hi, I have imported typescript definitions from @types/vexflow in my Angular project.
It works fine when using the Vexflow API, but I want to use EasyScore. But EasyScore is simply not defined in typescript definitions.
Am I doing something wrong?
To add some info, the following code works if I don't import typescript definitions, but fails to compile if I import them (Property 'Factory' does not exist on type 'typeof Flow'):
const vf = new Vex.Flow.Factory({
renderer: {elementId: 'vf', width: 500, height: 200}
});
const score = vf.EasyScore();
const system = vf.System();
system.addStave({
voices: [
score.voice(score.notes('C#5/q, B4, A4, G#4', {stem: 'up'})),
score.voice(score.notes('C#4/h, C#4', {stem: 'down'}))
]
}).addClef('treble').addTimeSignature('4/4');
vf.draw();
Hi -- I don't maintain the TypeScript definitions, but proper TypeScript support is on my roadmap.
The types for vexflow are incomplete, if you want to use them you have to fork them and add the missing definitions
or add to the DefinitelyTyped definitions as necessary and create a pull request, which has been done a few times. They're usually merged rather quickly.
@0xfe how are you imagining proper TypeScript support? Would you be open to porting the project to TypeScript, or are you thinking of maintaining the declarations?
No plans to port in the near term (hope to in the future), and not maintaining the declarations. For now, I'll let someone else own that. :-)
@alefz3r0 my merge request was accepted by DefinitelyTyped, I added some more types regarding EasyScore and Flow.Factory, please check if your code works now.
Make sure to use version @types/vexflow >= 1.2.36
You can of course always use everything without having definitions, like (stavenote as any).whatever or const stavenote: any = .... But adding to the DefinitelyTyped definitions is pretty straightforward.
Most helpful comment
@alefz3r0 my merge request was accepted by DefinitelyTyped, I added some more types regarding EasyScore and Flow.Factory, please check if your code works now.
Make sure to use version
@types/vexflow >= 1.2.36