testing-library / testing-library/react-testing-library

Typescript Migration

Open
#955 1 comment 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
19.7k
Forks
1.2k
Avg merge
3d 16h
Merged PRs (30d)
1

Description

Describe the feature you'd like:
  1. Similar to recent efforts at dom-testing-library to migrate the codebase to TS, the motivations for the same migration happening to this library apply here as well.

I've had a hard time finding previous issues/PRs that propose this migration in this repo, so I've created one, at least so we know where the maintainers stand, and if possible, serve as a centralized place to coordinate a piecemeal migration if given the greenlight.

  1. Here's a paraphrased from memory summary of arguments raised from around the testing-library family regarding TS:

    Premise: Typescript support benefits library users whether or not they use TS explicitly, so long as their IDEs support relevant intellisense ( which the most popular ones do )

    a. In-house type declarations ( versus those in DefinitelyTyped ) help maintain correctly versioned and maintained types.

    b. However, there is an effort overhead in terms of keeping track changes to logic with changes to exported types.

    c. Migrating the codebase to TS entirely allows maintainers to "automate" type declarations altogether, via existing type declaration build processes in kcd-scripts.

    d. However, that adds a barrier to entry for new contributors comfortable with JS and OSS contributions, but not TS.

    e. That being said, TS's rising popularity and similarity to JS anyways renders that, IMO, less of a problem.

    f. This means, assuming point (e) turns out to be true, that both contributors and consumers of this library will benefit from less-error-prone code, easier/faster understanding of library components / APIs and all around better developer ergonomics ( in my view )

Suggested implementation:
  1. I don't speak for the maintainers in the absolute slightest, so here's my best guess as to how best to do this.
  2. To reduce maintainer headache during code review, and simplify collaboration, the migration should probably be considered a long-ish running endeavor, with progress implemented via piecemeal/iterative PRs.
  3. kcd-scripts already includes support for TS and Babel, so initial setup with library entrypoints migrated to TS should serve as an appropriate starting point with minimal difficulty ( presumably )
  4. After step 2, I suppose it could as easily be an open bounty as to which files get migrated next, unless someone has a better idea.
  5. Perhaps after all or enough is migrated, the manually written type declaration files can be removed in favor of build-time emitted ones?
Describe alternatives you've considered:
  1. Keeping manual type declarations as-is
Teachability, Documentation, Adoption, Migration Strategy:
  1. If approved/merged changes result in actual changes in externally-facing APIs - or changes in the way they're best conveyed/expressed - as a result of TS migrations, then docs and other externally facing content that describes APIs should probably change. That being said, more accurate and explcit types will reduce the need for highly specific API descriptions.

  2. I am not sure what else this section is supposed to describe.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing library entrypoints, manually written type declaration files, and the TypeScript and Babel support in kcd-scripts. The issue proposes an iterative migration, so done would require an agreed scope, migration sequence, and criteria for replacing the manual declarations with emitted ones.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, developer-experience
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.