You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 [email protected]. 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. 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, 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:
Hello and thank you for your work.
The problem
I wanted to use the
universal
component with therender
prop inside. The types for it have been added to the bundled type definition file in #183.However, I'm using
[email protected]
. This change has not been released to v3 so the type definition I'm given doesn't allow me to userender
.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. 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
, 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:
type
withinterface
to make module augmentation possible, anddeclare 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:
mrsteele/dotenv-webpack#118 (comment)
What do you think?
The text was updated successfully, but these errors were encountered: