You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
import http2 from "http2"
There's no definition for the "http2", so we don't know how to resolve the type of the local http2 binding
varhttp2=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 placevarhttp2=<typeof_http>require('http2');
Sorry this is a bit confusing -- you'll want to use http1 in namespace positions (places where a dotted name produces a type), e.g. http1.ServerRequest. #10187 would create a way to do this unconfusingly by letting you alias the namespace side of http1.
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
Activity
RyanCavanaugh commentedon Sep 21, 2016
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
"http2", so we don't know how to resolve the type of the localhttp2bindingThis is using the underlying module loader.
You can write this to get the behavior you want
BobFrankston commentedon Sep 21, 2016
Thanks very much.
BobFrankston commentedon Sep 21, 2016
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 = ..."
RyanCavanaugh commentedon Sep 21, 2016
Sorry this is a bit confusing -- you'll want to use
http1in namespace positions (places where a dotted name produces a type), e.g.http1.ServerRequest. #10187 would create a way to do this unconfusingly by letting you alias the namespace side ofhttp1.BobFrankston commentedon Sep 21, 2016
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.
BobFrankston commentedon Sep 22, 2016
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.