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

Move type definitions to DefinitelyTyped #193

Open
karol-majewski opened this issue Aug 22, 2019 · 1 comment
Open

Move type definitions to DefinitelyTyped #193

karol-majewski opened this issue Aug 22, 2019 · 1 comment

Comments

@karol-majewski
Copy link

karol-majewski commented Aug 22, 2019

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 [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:

mrsteele/dotenv-webpack#118 (comment)

What do you think?

@ScriptedAlchemy
Copy link
Collaborator

I dont know typescript

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

No branches or pull requests

2 participants