简体   繁体   English

解析错误,我的类型检查器 function 上缺少分号

[英]Parsing error, missing semicolon on my Type checker function

I have created a correct Type checker function but the Parser tells me there is a missing semicolon but i don't know where.我创建了一个正确的类型检查器 function 但解析器告诉我缺少分号但我不知道在哪里。

My code我的代码

export const IsFirestoreUserData = (toVerify: any): toVerify is FirestoreUserData => {

  if (toVerify.profile === undefined) return false;
  if (toVerify.profile.name === undefined) return false;
  if (toVerify.profile.surname === undefined) return false;
  if (toVerify.conversations === undefined) return false;
  if (typeof toVerify.conversations !== "object") return false;

  return true;
};

The error错误

  Line 37:2:  Parsing error: Missing semicolon

  35 | export const IsFirestoreUserData = (
  36 |   toVerify: any
> 37 | ): toVerify is FirestoreUserData => {
     |  ^
  38 |   if (toVerify.profile === undefined) return false;
  39 |   if (toVerify.profile.name === undefined) return false;
  40 |   if (toVerify.profile.surname === undefined) return false;

Thanks for any help谢谢你的帮助

Idk why but i've restarted VSCode and it works fine now.不知道为什么,但我已经重新启动了 VSCode,它现在工作正常。

For others finding this same issue, it could be because you needed to restart ESLint after a configuration change such as adding the TypeScript parser.对于其他发现相同问题的人,可能是因为您需要在配置更改后重新启动 ESLint,例如添加 TypeScript 解析器。

You can do this by restarting VS Code, reloading VS Code, or restarting the extension host (fastest) .您可以通过重新启动 VS Code、重新加载 VS Code 或重新启动扩展主机(最快)来做到这一点。

  1. Press ctrl + shift + p (or your keybinding for opening the command palette)ctrl + shift + p (或用于打开命令面板的键绑定)
  2. Type restart extension host键入重启扩展主机
  3. Press enter按回车
  4. Wait for ESLint to come back online等待 ESLint 重新上线

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM