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
I get an error in the typescript compiler which I cant seem to understand how to fix. The error is: >ex.ts(3,27): error TS2307: Cannot find external module 'autobahn'.
I'm transpiling like: >tsc -m commonjs -t es5 "./typings/autobahn/autobahn.d.ts" ex.ts
and i also tried >tsc -m commonjs -t es5 ex.ts
..but funnily enough, it DOES produce the correct ES5 javascript source, and it runs and works fine ?!?
...and my code is simply:
/// <reference path="./typings/autobahn/autobahn.d.ts" />
import autobahn = require('autobahn');
class C {
x: number;
}
var myC = new C();`
..and I execute with >node ex
It's like tsc can't find the module/file 'autobahn' ???
I have used tsd to install the autobahn definitely types (it put it into the default folder ./typings/autobahn) and I reference it in my source code as you can see above.
All seems to be ok. As i mentioned, it seems to transpile just fine, the ES5 javascript output is as expected, and it runs.
It's a bit annoying having these error messages - when there is no error? Whats going on?
Cheers;
The text was updated successfully, but these errors were encountered:
This is actually quite subtle, the TS2307 error means it tried to look for a file called autobahn.ts and did not find it. It does this because autobahn.d.ts failed to declare the module as an "Ambient External Module".
You can write an additional d.ts file to import the incorrect d.ts and re-export the module. Please also consider submitting a patch to DefinitelyTyped.
TypeScript will always try to emit code, even if it thinks it's not going to work. In your case the code was fine but the definition file was incomplete, so it turned out to be useful behavior.
Hi team,
I get an error in the typescript compiler which I cant seem to understand how to fix. The error is:
>ex.ts(3,27): error TS2307: Cannot find external module 'autobahn'.
I'm transpiling like:
>tsc -m commonjs -t es5 "./typings/autobahn/autobahn.d.ts" ex.ts
and i also tried
>tsc -m commonjs -t es5 ex.ts
..but funnily enough, it DOES produce the correct ES5 javascript source, and it runs and works fine ?!?
...and my code is simply:
..and I execute with
>node ex
It's like tsc can't find the module/file 'autobahn' ???
On my Windows 7 box, I have the latest release of node and npm. I have used npm to install autobahnJS (just any standard javascript library https://github.com/tavendo/AutobahnJS), Typescript v1.5.0-beta (https://github.com/Microsoft/TypeScript) and tsd (the typescript definition manager https://github.com/DefinitelyTyped/tsd).
I have used tsd to install the autobahn definitely types (it put it into the default folder ./typings/autobahn) and I reference it in my source code as you can see above.
All seems to be ok. As i mentioned, it seems to transpile just fine, the ES5 javascript output is as expected, and it runs.
It's a bit annoying having these error messages - when there is no error? Whats going on?
Cheers;
The text was updated successfully, but these errors were encountered: