DEV Community

Dennis Zhang
Dennis Zhang

Posted on • Updated on

vscode 编辑器代码提示

方式1:语法使用了 TypeScript 的三斜线指令(Triple-Slash Directive),这是一种用于引用其他文件或类型定义的注释语法。

///<reference types="Cypress" />
Enter fullscreen mode Exit fullscreen mode

方式2:在根目录下创建jsconfig.json,将cypress的所有js文件添加进来

{
 "include":[
   "/node_modules/cypress",
   "cypress/**/*.js"
 ]
}
Enter fullscreen mode Exit fullscreen mode

方式3:安装插件 cypress snippets

在js文件中使用

@ts-check 通过启用类型检查功能,能够让 VS Code 对 JavaScript 代码进行静态类型分析。

// @ts-check
Cypress.Commands.add('myCustomCommand', () => {
  // 实现命令逻辑
});

Enter fullscreen mode Exit fullscreen mode

Top comments (0)