Skip to content

2.1.3

Compare
Choose a tag to compare
@ad-mailosaur ad-mailosaur released this 19 Mar 11:37
66d709a
 Fix global Cypress namespace augumentation (#14)

* Update version in package-lock.json

* Fix global Cypress namespace augumentation

This is fixed with 2 things:

1. For global namespace augumentation to work correctly, the augumentation needs to be in an "ambient" context (vs module context).
You can achieve ambient context in d.ts files in 2 ways:
  a.) by not using import/export keywords (using them toggles module context)
  b.) by wrapping namespace augumentation in `declare global {}` block - ambient context is inside this block.

See more info here:
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#augmenting-globalmodule-scope-from-modules
- https://github.com/Microsoft/TypeScript-Handbook/issues/180#issuecomment-195452691

2. For Typescript to be able to use provided type declarations, we need to point it to a correct d.ts file.
This is done by specifying path to this file in package.json's field "types".
With this, an application just needs to `import 'cypress-mailosaur'` and types just work

Co-authored-by: Milos Lajtman <[email protected]>