Skip to content

Stop global type leaks across commonJS modules #5346

Closed
@ziahamza

Description

@ziahamza

A lot of type definitions in DefinatelyType export CommonJS module types and a global type definition for popular libraries. I.E Jquery can be used directly from the window object but also using the require syntax.

But this causes Typescript to accept faulty code as correct. E.g using $ or jQuery directly in a commonjs module without requiring the module itself is compiled correctly, when in the first place it was a bug not to require the module.

So can there be a flag where if commonjs modules is enabled then global types are not supported, and only types exported through a module name?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions