You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EDIT: I do not want to use any instead of unknown here
Sorry if this seems trivial for most, but I cant get types from this package to work (or show up in VSCode even)
In my nuxt application, I want a reactive output like so:
// /composables/useMidi.tsexportfunctionuseMidi(){constjzzOutput=useState<unknown>('jzz-output',()=>null)...onMounted(()=>{jzzOutput.value=JZZ().openMidiOut(deviceName).or(()=>console.log(`useMidi: could not open device "${deviceName}"`)).then(()=>console.log(`useMidi: successfully opened device "${deviceName}"`))})...functionplayNote(note='C4'){jzzOutput.value.noteOn(CHANNEL,note,127).wait(500).noteOff(CHANNEL,note)}
The ts error I'm obviously getting in the playNote function is:
Property 'noteOn' does not exist on type '{}'
So now I want to replace unknown at the beginning of the composable with the correct type from jzz/index.d.ts, but I can't figure out how.
What I've tried
I tried using the main import JZZ with typeof etc.
experimented with import type JZZTypes from 'jzz' (also `from 'jzz/index.d.ts')
Added 'jzz' to ts.config.ts compilerOptoins.types
The text was updated successfully, but these errors were encountered:
Hi! Thanks for asking!
index.d.ts has not been updated for a while.
I would suggest to not use it at all and ignore the TS complains.
And I would really appreciate if any TS expert could help me to update the index.d.ts file
I'd love to help you, but.. while I feel more than comfortable in and around the browser, both typescript in depth and the how the entire npm ecosystem works is just a mystery to me.
The problem that you see may happen if you try to play the note before the MIDI Out is initialized.
From a functional standpoint my app works great; I just set "a challenge" for myself to honor "no-explicit-any" and satisfy typescript without any workarounds. I think even your "old" index.d.ts will help to satisfy typescriptin that case?
In any case, as I am trying to learn the ins and outs of npm+types, how is your package intended to work with types? Are there best practices packages like yours try to apply to?
EDIT: I do not want to use
any
instead ofunknown
hereSorry if this seems trivial for most, but I cant get types from this package to work (or show up in VSCode even)
In my nuxt application, I want a reactive output like so:
The ts error I'm obviously getting in the playNote function is:
So now I want to replace
unknown
at the beginning of the composable with the correct type fromjzz/index.d.ts
, but I can't figure out how.What I've tried
JZZ
withtypeof
etc.import type JZZTypes from 'jzz'
(also `from 'jzz/index.d.ts')'jzz'
to ts.config.tscompilerOptoins.types
The text was updated successfully, but these errors were encountered: