Make it possible to import various Cypress types #27973
Labels
type: feature
New feature that does not currently exist
type: typings
Issue related to Cypress types (for TypeScript)
What would you like?
We have a lot of imports like:
in the app.
This used to work fine until I tried to update TypeScript to a version that properly parses the
exports
field (5.2 but I think all >=5.0 might behave in a similar way) inpackage.json
, which for Cypress contains sub-entries like:Since there's no entry starting with
./types
, you can't import from this file like that.That may be fine but importing directly from
cypress
doesn't work:This happens for two reasons. First,
types/cypress-npm-api.d.ts
declares thecypress
module and imports ofcypress
lead to it. This can be hacked around by importing fromcypress/
instead:but
types/index.d.ts
is not a module - it does not import or export anything directly, it just has a bunch of pragmas like:/// <reference path="./net-stubbing.d.ts" />
It seems all the types are supposed to do is to type the built-in globals.
Why is this needed?
A lot of the types Cypress defines are useful for external consumers, e.g. to build custom interceptors, etc. It doesn't seem like there's a way to use the provided types with new TypeScript. Right now, it seems my choices are either hacking the
cypress
package to export what I need or to redefine all the types in the project - which may be quite daunting as they can get pretty complex.Other
No response
The text was updated successfully, but these errors were encountered: