Intellisense from JSDoc not working for imported t

2019-07-16 02:35发布

When using a, ES2015 class as a type in JSDoc it does not appear to work correctly in files that import that class via a require statement.

While working within the same file that the class was defined in, everything works as expected (shown below).

An example of JSDoc typing working correctly in the same file

While working within a different file the class appears to import correctly and show its constructor typing (shown below).

An example of an imported class working correctly

But when I try to use the class for typing (As done in the first image) it no longer considers my class as a valid type.

An example of an imported class not being accepted as a type

Here is the jsconfig I was using for this example

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "allowSyntheticDefaultImports": true
    }
}

Am I just missing something in my setup or is this the expected behavior?

1条回答
2楼-- · 2019-07-16 03:23

This answer may be a bit late, but line 6 of your last image should read:

@param {ExampleType} exampleType

With a lower case "exampleType", since that's what the param is named in the function.

查看更多
登录 后发表回答