Skip to content

Global namespace polluted in TypeScript projects #391

@jacksondoherty

Description

@jacksondoherty

When BigNumber is imported into TypeScript projects at least once, it pollutes the namespace and allows for usage without importing in other files. This is fine when used just as a type, but causes runtime errors if used such as const x = new BigNumber(1); These runtime errors are not caught by linting / typecheck.

This behavior is not present in the decimal.js package.

See this minimal reproducible example here. This is a nextjs hello world app with decimal.js and bignumber.js imported, and shows how the latter pollutes the namespace.

Issue #143 ran into a similar issue – apparently it was fixed, but perhaps not fully or the concerning behavior returned.


UPDATE (see below): next.js build catches the missing import, but React Native Expo build does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions