TypeScript 找不到名称"SpeechGrammarList",这是在"DOM"中实现的



SpeechGrammarList,但这是Web Speech API的一部分,该接口是在"dom"中实现的。为什么TS仍然给出这个错误?

代码:

export interface SpeechRecognitionProperties {
grammars?: SpeechGrammarList; //TS2304: Cannot find name 'SpeechGrammarList'.
lang?: string;
}

"typescript": "^4.4.4"

tsconfig:

{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["./src"]
}

这是TS 4.4的自由变更。见https://github.com/Riley-Brown/react-speech-to-text/issues/23

相关内容

  • 没有找到相关文章

最新更新