-
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
import inconsistent? #11025
Comments
This is what we generally call a "forced" import. It doesn't create a local binding, so there's no reason to force it to resolve to a known module. These are usually used to load non-code resources anyway.
There's no definition for the var http2 = require("http2"); This is using the underlying module loader. You can write this to get the behavior you want import _http = require('http'); // don't use _http in any other place
var http2 = <typeof _http>require('http2'); |
Thanks very much. |
Reopening this. First, the <typeof ..> notation is not at all obvious until you see it. Thanks. But now in using "http.
same for "var http2 = ..." |
Sorry this is a bit confusing -- you'll want to use |
Thanks. Yeah -- getting to the truth by lying. I'll have to take the time go through the aliasing procedure given the overlapping mechanisms. And, more generally,how to get the declarations for importing JavaScript but that's probably best for the suggestions forum. |
OK, gets stranger. Turns out that https://github.com/molnarg/node-http2 has an index.d.ts file and even mentions Typescript 1.8 compatibility. ! But it's unclear how to use it. My gut feel is that it should be found automatically. So I explicitly added
which generates declaration errors. I feel this is close but so far. |
TypeScript Version: 1.8.36.0
Code
Expected behavior:
Actual behavior:
This may be my confusion. I've added the http2 module with npm. The first format does not produce an error (though is not very useful). The second form does.
This may be my confusion. My sense is that import works if I have a definitely typed file. But haven't found the exact documentation. I do have a related question - how do I say that http2 should use the http module definition?
The text was updated successfully, but these errors were encountered: