我试图让Google一键使用类型记录,我得到的错误是Cannot find name 'googleyolo'.ts(2304)
<script src="https://smartlock.google.com/client"></script>
...
useEffect(() => {
const clientId = process.env.REACT_APP_GOOGLE_CLIENT_ID
const getID = async () => {
const credential = await googleyolo.retrieve({
// ^ error
supportedAuthMethods: ["https://accounts.google.com"],
supportedIdTokenProviders: [{ uri: "https://accounts.google.com", clientId }]
});
console.log(credential)
}
getID();
}, []);我可以写一个接口
interface YoloInterface {
retrieve: any
cancelLastOperation: any
hint: any
disableAutoSignIn: any
}但我不知道怎么告诉TypeScript这件事?
发布于 2020-04-09 01:23:48
您应该在模块顶部声明googleyolo如下所示:
declare var googleyolo: any; // or any way you see fit或者创建声明文件。
https://stackoverflow.com/questions/61112354
复制相似问题