capacitor-community / speech-recognition

MIT License
94 stars 53 forks source link

fix type narrowing for listener #84

Closed khromov closed 8 months ago

khromov commented 8 months ago

Pull request checklist

Fixed type narrowing on event listeners

khromov commented 8 months ago

After further testing the existing types work, I think perhaps the language server wasn't picking them up automatically without a restart which confused me. I tried in a brand new projects and this correctly type narrows the value of result:

npm i -D @capacitor-community/speech-recognition@5.0.0-dev.f11750d.1711357142
SpeechRecognition.addListener('partialResults', (result) => {
    console.log('Result:', result.matches);
});

SpeechRecognition.addListener('listeningState', (result) => {
    console.log('listeningState:', result.status);
});