Stage | Status |
---|---|
Approved | ✅ |
Adopted | ✅ |
Primer React components 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 components 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.
We will rewrite Primer React components in TypeScript.
- Type definitions can be generated by the TypeScript compiler, eliminating bugs caused by hand-written type definitions.
- Engineers can upstream components from other TypeScript projects at GitHub without having to remove type annotations, improving the contributor experience.
- We can refactor components with increased confidence.
- Component prop documentation can be generated by react-docgen-typescript, eliminating inaccurate and out-of-date hand-written prop documentation.
- New contributors will need some familiarity with TypeScript in order to make code contributions.