-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Imported namespaces aren't recognized in --checkJs #16489
Comments
Actually, the above example works because of type inference, and not because of the annotation. const {Foo} = require('./test-externclassdef');
// this doesn't work a is still of type any
/** @type {Foo} */
let a;
a = new Foo(); |
I think I have a similar issue, it might even be the same one but I'm not entirely sure. // some-module.js
declare function SomeModule(opts?: SomeModule.Options);
declare namespace SomeModule {
interface Options {
enabled?: boolean
}
}
export = SomeModule; // my-code.js
const SomeModule = require('./some-module');
// Causes "Cannot find namespace 'SomeModule'" error
/** @type {SomeModule.Options} */
const options = {
enabled: true
}; Would the fix for this issue help my case too? |
@lumaxis yes, I believe so. |
I didn't want to open up another issue but this seems like it could be related to the issue I'm having.
Works with --checkJS, but won't run in NodeJS
Doesn't work with --checkJS, but works with NodeJS:
Error: |
+1 on this. I can't annotate JS-doc style to get some intellisense when I'm in a node JS project using commonjs, which is very annoying. |
Will this also allow to import an interface from a ts file? What do you think of adding a
Please see also #19547 for a more detailed example |
I think you are looking for #14377 |
@cesarvarela You appear to be wrong; TypeScript (at least the latest version thereof) seems to correctly deduce |
TypeScript Version: nightly (2.5.0-dev.20170613)
Code
test-externclassdef.js
test-externclass.js
Expected behavior:
No error
Actual behavior:
#16316 fixes the first kind of import (which I'm really thankful for), but the second kind is still an error.
The text was updated successfully, but these errors were encountered: