Skip to content

Conversation

@pgoldberg
Copy link

Declaring a global module with declare module 'react-draggable' is unnecessary, and can cause type pollution if multiple versions of react-draggable end up in a package.

This is exemplified in this repro: https://github.com/pgoldberg/react-draggable-typings-bug

The global module declaration is not necessary. Typescript will appropriately associate the typings with the react-draggable module, since the typings are declared in the package.json here:

"typings": "./typings/index.d.ts",

@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Closing this PR as stale. This TypeScript namespace cleanup PR has been open since 2022 without being merged. If this typing issue persists, please open a fresh PR against the current codebase. Thank you for the contribution!

@STRML STRML closed this Dec 31, 2025
@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Reopening - this fixes a legitimate TypeScript type pollution issue.

@STRML STRML reopened this Dec 31, 2025
@gluxon
Copy link

gluxon commented Dec 31, 2025

Thanks @STRML!

I believe we ended up working around this issue with a patch on our side, so the issue does still exist. A fix for this would still be valuable!

STRML added a commit that referenced this pull request Dec 31, 2025
Removes the `declare module 'react-draggable'` wrapper from TypeScript
definitions and uses direct exports instead. This fixes type pollution
issues when multiple versions of react-draggable end up in a project's
dependencies.

The global module declaration is unnecessary as TypeScript will
automatically associate the typings with the `react-draggable` module
since they're declared in package.json.

Closes #690
@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Closing in favor of #787 which implements this fix against the current codebase. Thank you for the contribution!

@STRML STRML closed this Dec 31, 2025
STRML added a commit that referenced this pull request Dec 31, 2025
Removes the `declare module 'react-draggable'` wrapper from TypeScript
definitions and uses direct exports instead. This fixes type pollution
issues when multiple versions of react-draggable end up in a project's
dependencies.

The global module declaration is unnecessary as TypeScript will
automatically associate the typings with the `react-draggable` module
since they're declared in package.json.

Closes #690
STRML added a commit that referenced this pull request Dec 31, 2025
Removes the `declare module 'react-draggable'` wrapper from TypeScript
definitions and uses direct exports instead. This fixes type pollution
issues when multiple versions of react-draggable end up in a project's
dependencies.

The global module declaration is unnecessary as TypeScript will
automatically associate the typings with the `react-draggable` module
since they're declared in package.json.

Closes #690
STRML added a commit that referenced this pull request Dec 31, 2025
#787)

Removes the `declare module 'react-draggable'` wrapper from TypeScript
definitions and uses direct exports instead. This fixes type pollution
issues when multiple versions of react-draggable end up in a project's
dependencies.

The global module declaration is unnecessary as TypeScript will
automatically associate the typings with the `react-draggable` module
since they're declared in package.json.

Closes #690
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.

3 participants