-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSDoc Does not Pick up Type imported using Require #14056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
@mhegazy see the repro case over in microsoft/vscode#21933 in particular, notice how to behavior is different for |
For record keeping and improving searchability of this issue, the same problem occurs with local variables, it is not limited to function parameters: var Foo = require("./foo");
/** @type {Foo} */
var bar; // VSCode (via TypeScript engine) considers `bar` to be of type `any` Also note that the recommended workaround of using the import syntax only applies if you are writing ES2015+, in which case you really should be using import syntax anyway. For code written in ES5 I don't believe there is any workaround to this issue. |
If I define I've googled this a lot and I can't find any documentation on how to make it a type. Now that TypeScript emits errors when I try to do this, I think that error is a good place to provide guidance on how to make it a type. |
Based on the discussion in #15747, we want to look up the reference as a value of the look up as a type failed, and add special handling for classes. |
From microsoft/vscode#20238
TypeScript Version: 2.1.6
Code
foo.js:
index.js:
Expected behavior:
The type of
param
isFoo
Actual behavior:
The type of
param
isany
.If I change the import to
import {Foo} from './foo'
, the type ofparam
is correctThe text was updated successfully, but these errors were encountered: