IntelliSense for Cypress library #30068
-
|
Reading through the documentation, I can't understand why it is necessary to put the reference to the Cypress library inside jsconfig.json/tsconfig.json to use IntelliSense on VSCode(in addition to the Triple slash directives mode) and it is not possible to use package.json. Is there any trick that allows this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
IntelliSense in VS Code is driven by the TypeScript language service, which reads The confusion is that the types field does matter, but only for a package’s own declarations: The three supported ways (all editor-side): // 1. per-file
/// <reference types="cypress" />// 2. jsconfig.json (JS projects)
{ "include": ["./node_modules/cypress", "cypress/**/*.js"] }// 3. tsconfig.json (TS projects)
{ "compilerOptions": { "allowJs": true, "types": ["cypress"] }, "include": ["**/*.*"] }For project-wide coverage without per-file directives, use |
Beta Was this translation helpful? Give feedback.
IntelliSense in VS Code is driven by the TypeScript language service, which reads
tsconfig.json/jsconfig.json— not your project’spackage.json. There’s nopackage.jsonfield the language service consults to inject global types, so there’s no trick to move it there.The confusion is that the types field does matter, but only for a package’s own declarations:
/// <reference types="cypress" />resolvesnode_modules/cypress/package.json→types/index.d.ts. Your project’spackage.jsoncan’t register those Cypress globals (cy, Cypress, expect) for the editor.The three supported ways (all editor-side):