Skip to content

tsc shows error 'Cannot find external module', but it works !?! #3808

@bradws

Description

@bradws

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:

/// <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' ???

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions