microsoft / microsoft/TypeScript

VSCode JSDoc doesn't recognize members that are classes from default imported object.

Open
#36,514 1 comment 0 reactions 1 assignee View on GitHub

@rachelgshaffer is already working on this.

Since Jun 11, 2020.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

VSCode Version: 1.41.1

Search Terms:
jsdoc export import class object type

Code

a.js

export default class A {
	constructor() {
		this.m = 2;
	}
}

b.js

export default class B {
	constructor() {
		this.n = 4;
	}
}

lib.js

import A from './a';
import B from './b';

const Lib = {
	A,
	B
};

export default Lib;

app.js

import Lib from './lib';

/**
 * @param {Lib.A} a
 * @param {Lib.B} b
 */
function foo(a, b) {
}

function bar() {
	const a = new Lib.A();
	foo(new Lib.A(), new Lib.B());
}

Expected behavior:
When I hover over the Lib in the @param jsdoc of app.js foo function, the tooltip should read something similar to what happens in the bar function:

(alias) const Lib: {
    A: typeof A;
    B: typeof B;
}
import Lib

And when I hover over the Lib.A in the same area, the tooltip should read something similar to what happens in the bar function:

(property) A: new () => A

Actual behavior:
When I hover over the Lib or Lib.A in the @param jsdoc of app.js foo function, the types are any, not being recognized as a particular type.

The hovering over types in actual javascript within the bar function works great.

Related Issues:

I searched, but I'm not seeing any similar issue. Maybe I'm missing something obvious?

Notes
I don't believe I saw this behavior in earlier versions of VSCode (maybe even October or September 2019 releases). My code base hasn't changed, but the editor has been upgraded.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.