-
Notifications
You must be signed in to change notification settings - Fork 154
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: chore(typescript): add TypeScript typings #16
WIP: chore(typescript): add TypeScript typings #16
Conversation
I'm not sure if this is the correct type, but it does at least allow chaining to work
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.
Looks right to me. There's an example here https://github.com/cypress-io/add-cypress-custom-command-in-typescript/blob/aff24be0/README.md but your code looks more correct and up-to-date than the one in the example.
I've heard about a way to test typings, I'm AFK but maybe we could enumerate the functions the dom library supports in order to make sure we cover everything. I'll look into it tomorrow. Thanks so much for helping out @sompylasar! |
Please let me know when you find the way, I'd like to learn it for general awareness. |
I think it's worth reaching out to @kentcdodds, as I don't want to add to his already busy workload for a workflow that he doesn't use day to day. My twitter is @aaromcadam @sompylasar if you want to pick things up in the morning (I'm UTC time) |
@sompylasar Here's an intro to type testing with dtslint |
there's a few things I'm unsure of: * should we shadow the typings directory of dom-testing-library for easier maintainance? * allBy methods: will the list of items be typed correctly?
} from 'dom-testing-library' | ||
|
||
export namespace Cypress { | ||
type GetByAttribute = (id: Matcher, options?: MatcherOptions) => Chainable |
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've attempted to copy the implementation here: https://github.com/kentcdodds/dom-testing-library/blob/master/typings/queries.d.ts
Hi @sompylasar, could you give this another look when you get a chance? Thanks! |
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.
LGTM (if it works, can't test it myself), thanks!
🎉 This PR is included in version 2.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the |
Do we have any active TypeScript users? These definitions aren't being picked up by VSCode for me. |
Hi @aaronmcadam, you should probably use global augmentation instead declare global {
namespace Cypress {
...
}
} |
What: Attempts to fix #12. I've only added support for
getByTestId
to ensure that I've done things correctly. I wonder if there's an easy way to keep up to date withdom-testing-library
?Why: For TypeScript support
How: Added a
typings
directory and added a reference topackage.json
.I've tried to copy how cypress adds its own types for chainable methods and custom commands: https://github.com/cypress-io/add-cypress-custom-command-in-typescript/blob/master/README.md
Checklist: