Skip to content
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

feature: include typescript module declaration #292

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions packages/global-jsdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"module": "./esm/index.mjs",
"main": "./commonjs/index.cjs",
"types": "types/index.d.ts",
"files": [
"commonjs/*",
"esm/*"
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;
}