Skip to content

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

@fiddleplum

Description

@fiddleplum

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.

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions