Skip to content

In JS, aliasing exports = {} omits the expected string index signature #25687

Closed

Description

From adonis-framework in the user tests.

// Filename: util.js
const util = exports = module.exports = {}
util.existy = function() { }

Expected behavior:

No error, and import('util') has a property existy. (Ideally util would also have a property existy inside util.js, but this is not true in 2.9.2 either.)

Actual behavior:

Error: Property 'x' does not exist on type '{}', but require('util') does have a property existy: () => void.

Activity

  1. sandersn commented on Jul 16, 2018

    @sandersn
    MemberAuthor

    #25619 causes module.exports assignments to be contextually typed, and we don't add an index signature when there is a contextual type.

    This wouldn't be a problem, except that util wasn't really the type of the module anyway, so without the index signature, existy didn't really exist.

  2. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions