javascripttypescriptspeech-recognitionyarn-v2

How do I remove `cannot find name` for the SpeechRecognition API in Typescript, aka what does 'Now provided by --lib dom' mean?


recognition: SpeechRecognition | undefined;
this.recognition = new webkitSpeechRecognition(); 
this.recognition.onresult = (event: SpeechRecognitionEvent) => {});

Each throw a cannot find name warning for each of SpeechRecognition, webkitSpeechRecognition, and SpeechRecognitionEvent

I tried yarn -D add @types/webspeechapi but it produced an error, and indeed it is deprecated with the message Now provided by --lib dom. Unfortunately, I have no idea what this means!


Solution

  • try this instead npm install --save @types/dom-speech-recognition worked for me