90poe / vscode-cy-helper

VS Code IDE Extension for Cypress.io

Home Page:https://marketplace.visualstudio.com/items?itemName=Shelex.vscode-cy-helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option for generating tsconfig.json

joszo opened this issue · comments

I think a useful feature would adding option for generating tsconfig.json

Usually, in a new project, I create in root/cypress folder the tsconfig.json file with below syntax (I always copy it from the other project because I don't like to remember that kind of stuff)

{
    "compilerOptions": {
      "allowJs": true,
      "baseUrl": "../node_modules",
      "types": [
        "cypress"
      ]
    },
    "include": [
      "**/*.*"
    ]
  }

It would really improve the setup process if people like to use autocomplete in spec file easily.

@joszo
Thank you for creating issue!

Yeah, I think to resolve it with next steps:

  1. Command palette item to generate default tsconfig.json file.
  2. Check before Cypress: Generate Custom Command Types if tsconfig.json exists, and if not - prompt to create default one.

@joszo
Just published version 0.3.7

  • now there is command palette item Cypress: Create default tsconfig.json file
  • after Cypress: Generate Custom Command Types there is prompt to create tsconfig.json file if it is not found in workspace.

I've tested your solution it generates the tsconfig.json as excepted, but I found small issue for edge case scenario:

  1. Open commands.js
  2. Right-click -> Cypress: Generate Custom Command Types
  3. Types will be generated
  4. In the right bottom corner, there is information about missing tscofing.json
  5. Click yes
  6. Remove tsconfig.json
  7. Right-click -> Cypress: Generate Custom Command Types

Actual result: The popup No tsconfig.json file detected, do you want to create? is not displayed. User have to reopen the VSC, and then everything works correctly.

Expected result: Popup should appear

@joszo
That is because of way how filesystem was handled.
After extension activation whole folder was scanned and saved in memory. Only when file was deleted, extension rescanned whole folder again to avoid file read errors.
I have changed the way how filesystem is handled in v0.3.8 so this case should be fixed after you upgrade extension.

Tested on v0.3.8, the tsconfig.json file is generated without reopening the vsc.