microsoft / microsoft/TypeScript

Support evolving the type with assignments for expando object

Open
#12,416 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

In Discussion Suggestion VS Code Tracked
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Copied from https://github.com/Microsoft/TypeScript/issues/12278#issuecomment-261000712
OP = @abgivant

I use a similar module pattern in an application I'm working on, and the lack of IntelliSense/definitions for those has been an issue for me as well.

Mine follow this basic pattern:

module.exports = function(x, y, z) {
  var exports = {};
  exports.method = function() {
    // Something that might use x, y, or z
  };
  return exports;
}

Would it be possible to do something like include an option in the jsconfig.json file to specify a property name or list of names to track when determining module exports?

Maybe something like this?

{
  "moduleOptions": {
    "exportProperty": ["exports", "this"]
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CommonJS module pattern and the proposed moduleOptions setting in jsconfig.json. Reproduce the missing IntelliSense and definitions behavior, then trace TypeScript’s handling of assignments to expando objects; done means the requested export properties evolve in type information and the configuration behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.