SpeechGrammarList的TS错误,但这是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"]
}发布于 2021-10-27 03:38:41
这是一个TS4.4libdom变化。请参阅https://github.com/Riley-Brown/react-speech-to-text/issues/23
https://stackoverflow.com/questions/69732466
复制相似问题