Skip to content

Commit

Permalink
feature: include typescript module declaration (#292)
Browse files Browse the repository at this point in the history
* feature: include typescript module declaration

* feat: include typescript types as part of the package in the next release
  • Loading branch information
to-codando authored Mar 20, 2023
1 parent 42d9325 commit e2682e1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,27 @@ import jQuery from 'jquery'
// ...
```

## Typescript

The library includes automatic support providing the necessary type declarations for an integration without further configuration.

```ts
import globalJsdom from "global-jsdom";

describe("Typescript test example", () => {
let cleanup: { (): void };

before(() => {
cleanup = globalJsdom();
});

after(() => {
cleanup();
});

})
```

## Migration from `jsdom-global`
1. `browserify` support is dropped - I have no way to test this and `webpack` started giving higher priority to the `browser` field in `package.json` than `module`

Expand Down
4 changes: 3 additions & 1 deletion packages/global-jsdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
},
"module": "./esm/index.mjs",
"main": "./commonjs/index.cjs",
"types": "types/index.d.ts",
"files": [
"commonjs/*",
"esm/*"
"esm/*",
"types/*"
],
"bugs": {
"url": "https://github.com/modosc/global-jsdom/issues"
Expand Down
7 changes: 7 additions & 0 deletions packages/global-jsdom/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module "global-jsdom" {
import { ConstructorOptions } from "jsdom";

function globalJsdom(html?: string, options?: ConstructorOptions): () => void;

export = globalJsdom;
}

0 comments on commit e2682e1

Please sign in to comment.