-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - TypeScript Support Doc #466
Changes from 4 commits
b5b5a90
3422b73
9523a44
a456176
0c0b382
2ee56e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: TypeScript Support | ||
comments: false | ||
--- | ||
|
||
Cypress ships with {% url "official type declarations" https://github.com/cypress-io/cypress/tree/develop/cli/types %} for {% url "TypeScript" https://www.typescriptlang.org/ %}. | ||
|
||
# Intellisense | ||
|
||
In order to get intellisense working, you can try a few approaches: | ||
|
||
## Triple-Slash Directives | ||
|
||
We have seen success in VS Code with intellisense by simply adding a [triple-slash directive](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) to the head of your JavaScript testing file. This is the simplest way to get intellisense working. | ||
|
||
```js | ||
/// <reference types="Cypress" /> | ||
``` | ||
|
||
{% img /img/guides/typescript-intellisense-with-reference.gif %} | ||
|
||
## tsconfig | ||
|
||
If your project is written in TypeScript, you may find it more convenient to include Cypress in your `tsconfig.json`. | ||
|
||
```json | ||
{ | ||
"include": [ | ||
"integration/*.ts", | ||
"support/*.ts", | ||
"../node_modules/cypress" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this JSON block should be: If you write your tests in TypeScript, you may find it more convenient to add a {
"compilerOptions": {
"strict": true,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"],
},
"include": [
"**/*.ts"
]
} The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. omg, thank you! I was struggling 😅 I think this has helped finally push it to a shippable state. |
||
] | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this method is limited to TypeScript. It should work on JavaScript files as well in VSCode, Atom and probably more editors/IDEs. I ask because the section is labeled "TypeScript Support" which JavaScript developers might just skip over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will have to think about a good place to mention this elsewhere in the docs.