Skip to content

Salsa works for imported module members but not within the exporting module #15809

@pitaj

Description

@pitaj

TypeScript Version: 2.3.2

Code

// ==== main.js ====

const foobar = require('./module');

foobar.foo
foobar.bar

// ==== module.js ====

/** @type {{ spacing: number, perLine: number }} */
const defaults = {
  spacing: 2,
  perLine: 6,
};

/**
 * @param {{ spacing: number, perLine: number }} options
 * @returns {{ spacing: number, perLine: number }}
 */
exports.foo = (options) => Object.assign({}, defaults, options);

/**
 * @param {string} name
 * @param {number} age
 */
exports.bar = (name, age) => {
  return `The person named "${name}" is ${age} years old!`;
};

I emulated the expected behavior by adding this at the bottom of module.js:

/** @type {{ foo(options: { spacing: number, perLine: number }): { spacing: number, perLine: number }, bar(name: string, age: number): string }} */
const exports = module.exports;

Expected Behavior

IntelliSense in main.js

Autocomplete should work
image

Hovering over references should work
image

IntelliSense in module.js

Hovering over the definitions should work
image

Autocomplete should work
image

Hovering over references should work
image

Actual Behavior

IntelliSense in main.js

Works just fine in autocomplete
image

Or when hovering over references to imports
image

Failing IntelliSense in module.js

It works when hovering over the members themselves
image

But doesn't work when trying to get autocompletes
image

Nor when hovering over other references to exports
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions