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

Replace index.d.ts with generated type definitions #1147

Merged
merged 9 commits into from
Apr 1, 2021

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Mar 31, 2021

Problem

Primer React was originally released without TypeScript type definitions, making it difficult for engineers to consume the library in TypeScript applications. In July 2019, we created an ambient declaration file (index.d.ts) file to provide type definitions for TypeScript applications without having to rewrite Primer React components in TypeScript.

index.d.ts has been an effective stopgap, enabling teams to build complex applications with Primer React and TypeScript. However, because index.d.ts is disconnected from the implementation code, we've struggled to keep the type definitions up-to-date and accurate, as evidenced by many TypeScript bug reports. As the library continues to grow in size and complexity, manually maintaining type definitions will become unsustainable.

Solution

Now that all our components have been rewritten in TypeScript, we can use the TypeScript compiler to generate type definitions instead of manually maintaining an ambient declaration file. This PR removes our manually maintained index.d.ts file and updates the package.json to reference the generated type definitions.

Checklist

  • Export prop types from index.ts 21c806c
  • Update typings field in package.json to reference generated type definitions bab3e96
  • Test generated type definitions in an application
  • Fix type errors
  • Delete index.d.ts
  • Write changeset

@changeset-bot
Copy link

changeset-bot bot commented Mar 31, 2021

🦋 Changeset detected

Latest commit: db47820

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/components Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 31, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/71dkPf5BtMmpWeFP8dTzMfV9YDHc
✅ Preview: https://primer-components-git-colebemis-replace-indexdts-primer.vercel.app

@colebemis colebemis marked this pull request as draft March 31, 2021 23:36
@vercel vercel bot temporarily deployed to Preview April 1, 2021 00:20 Inactive
@colebemis colebemis force-pushed the colebemis/replace-index.d.ts branch from f7bdcbf to 1c7ea7f Compare April 1, 2021 04:36
@vercel vercel bot temporarily deployed to Preview April 1, 2021 15:54 Inactive
@colebemis colebemis force-pushed the colebemis/replace-index.d.ts branch from f66e4bc to 1c7ea7f Compare April 1, 2021 16:23
@vercel vercel bot temporarily deployed to Preview April 1, 2021 17:04 Inactive
Copy link
Member

@dgreif dgreif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't realize this was a Draft PR before I started reviewing 😄 . Ignore anything you already have fixed up

src/index.ts Show resolved Hide resolved
src/index.ts Show resolved Hide resolved
tsconfig.json Show resolved Hide resolved
@colebemis colebemis marked this pull request as ready for review April 1, 2021 18:37
@colebemis colebemis mentioned this pull request Apr 1, 2021
53 tasks
@vercel vercel bot temporarily deployed to Preview April 1, 2021 19:33 Inactive
@vercel vercel bot temporarily deployed to Preview April 1, 2021 19:48 Inactive
@vercel vercel bot temporarily deployed to Preview April 1, 2021 19:59 Inactive
Copy link
Member

@dgreif dgreif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, this is a major accomplishment! 🏆 🚀

@colebemis colebemis merged commit 6f1e7af into main Apr 1, 2021
@colebemis colebemis deleted the colebemis/replace-index.d.ts branch April 1, 2021 20:11
@github-actions github-actions bot mentioned this pull request Apr 1, 2021
@dgreif dgreif mentioned this pull request Apr 7, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants