From fe73cc6607e7fa4e44a4235e6745e4b06667160b Mon Sep 17 00:00:00 2001 From: Alex Krolick Date: Sun, 11 Aug 2019 16:18:13 -0700 Subject: [PATCH 1/2] chore(typescript): remove typings BREAKING: remove TypeScript definitions from repo --- package.json | 4 ---- typings/index.d.ts | 49 ---------------------------------------------- 2 files changed, 53 deletions(-) delete mode 100644 typings/index.d.ts diff --git a/package.json b/package.json index ff29c1af..a04f9a54 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "description": "Simple and complete React DOM testing utilities that encourage good testing practices.", "main": "dist/index.js", "module": "dist/@testing-library/react.esm.js", - "typings": "typings/index.d.ts", "engines": { "node": ">=8" }, @@ -23,7 +22,6 @@ }, "files": [ "dist", - "typings", "cleanup-after-each.js", "dont-cleanup-after-each.js", "pure.js" @@ -50,8 +48,6 @@ "devDependencies": { "@reach/router": "^1.2.1", "@testing-library/jest-dom": "^4.0.0", - "@types/react": "^16.9.1", - "@types/react-dom": "^16.8.5", "kcd-scripts": "^1.5.2", "react": "^16.9.0", "react-dom": "^16.9.0" diff --git a/typings/index.d.ts b/typings/index.d.ts deleted file mode 100644 index ab4528e2..00000000 --- a/typings/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -import {queries, Queries, BoundFunction} from '@testing-library/dom' -import {act as reactAct} from 'react-dom/test-utils' - -export * from '@testing-library/dom' - -export type RenderResult = { - container: HTMLElement - baseElement: HTMLElement - debug: (baseElement?: HTMLElement | DocumentFragment) => void - rerender: (ui: React.ReactElement) => void - unmount: () => boolean - asFragment: () => DocumentFragment -} & {[P in keyof Q]: BoundFunction} - -export interface RenderOptions { - container?: HTMLElement - baseElement?: HTMLElement - hydrate?: boolean - queries?: Q - wrapper?: React.ComponentType -} - -type Omit = Pick> - -/** - * Render into a container which is appended to document.body. It should be used with cleanup. - */ -export function render( - ui: React.ReactElement, - options?: Omit, -): RenderResult -export function render( - ui: React.ReactElement, - options: RenderOptions, -): RenderResult - -/** - * Unmounts React trees that were mounted with render. - */ -export function cleanup(): void - -/** - * Simply calls ReactDOMTestUtils.act(cb) - * If that's not available (older version of react) then it - * simply calls the given callback immediately - */ -export const act: typeof reactAct extends undefined - ? (callback: () => void) => void - : typeof reactAct From 152e438a6b6420b8074c2dc9c361a4ff5ab2d49c Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Thu, 15 Aug 2019 13:14:59 -0600 Subject: [PATCH 2/2] add @types/testing-library__react --- CONTRIBUTING.md | 35 +++-------------------------------- package.json | 2 +- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7cc35e72..de766c7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,45 +26,16 @@ series [How to Contribute to an Open Source Project on GitHub][egghead] > can make all of your pull request branches based on this `master` branch. > Whenever you want to update your version of `master`, do a regular `git pull`. -## Add yourself as a contributor - -This project follows the [all contributors][all-contributors] specification. To -add yourself to the table of contributors on the `README.md`, please use the -automated script as part of your PR: - -```console -npm run add-contributor -``` - -Follow the prompt and commit `.all-contributorsrc` and `README.md` in the PR. If -you've already added yourself to the list and are making a new type of -contribution, you can run it again and select the added contribution type. - ## Committing and Pushing changes Please make sure to run the tests before you commit your changes. You can run `npm run test:update` which will update any snapshots that need updating. Make sure to include those changes (if they exist) in your commit. -### opt into git hooks - -There are git hooks set up with this project that are automatically installed -when you install dependencies. They're really handy, but are turned off by -default (so as to not hinder new contributors). You can opt into these by -creating a file called `.opt-in` at the root of the project and putting this -inside: - -``` -pre-commit -``` - -### Add typings +### Update Typings -If your PR introduced some changes in the API, you are more than welcome to -modify the Typescript type definition to reflect those changes. Just modify the -`/typings/index.d.ts` file accordingly. If you have never seen Typescript -definitions before, you can read more about it in its -[documentation pages](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) +The TypeScript type definitions are in the +[DefinitelyTyped repo](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__react) ## Help needed diff --git a/package.json b/package.json index a04f9a54..56aa7346 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "dependencies": { "@babel/runtime": "^7.5.5", "@testing-library/dom": "^6.0.0", - "@types/react-dom": "*" + "@types/testing-library__react": "^9.1.0" }, "devDependencies": { "@reach/router": "^1.2.1",