faceyspacey / faceyspacey/react-universal-component
Move type definitions to DefinitelyTyped
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
Hello and thank you for your work.
### The problem
I wanted to use the `universal` component with the `render` prop inside. The types for it have been added to the bundled type definition file in #183.
However, I'm using `react-universal-component@3.0.2`. This change has not been released to v3 so the type definition I'm given doesn't allow me to use `render`.
### My options
#### Update to v4
I could do that' but updating a major version means having to face backward-incompatible changes. I'm fine with v3. I just want type definitions to work.
#### Module augmentation
It's not an option in this case. `Options` are defined as a [type, not as an interface](https://github.com/faceyspacey/react-universal-component/blob/cbb7898b580bb48707990b3dcef9d9481df2f219/index.d.ts#L81). Interfaces can be augmented. Type aliases cannot.
#### Local module override
Not an option in this case as well. Because the bundled type definition [is already using `declare module`](https://github.com/karol-majewski/react-universal-component/blob/cbb7898b580bb48707990b3dcef9d9481df2f219/index.d.ts#L1), TypeScript won't let me do the same in my repository.
#### Use `patch-package`
This would work, but it would work just for me. Everyone else sharing my use case will continue to have the same problem.
#### Fixing the definitions upstream
I _could_:
- replace `type` with `interface` to make module augmentation possible, and
- delete `declare module` (since it's not correct to begin with) to make overrides possible for future users.
but that still leaves us with the problem of versioning. If there is v3 and v4 and their API surface is different, then they should have separate type definitions.
This leads us to...
### The solution
Move the type definitions for `react-universal-component` to DefinitelyTyped.
DT has an infrastructure for deploying quality type definitions that supports versioning. Not only it's easier to find maintainers, it's also easier to write correct definitions for certain rules are enforced by `dtslint`.
See what the TypeScript team recommends in situations like this:
https://github.com/mrsteele/dotenv-webpack/pull/118#issuecomment-376059077
What do you think?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.