Reputation: 11895
I'm converting a working JavaScript file to TypeScript.
I use Express in this file, so I've added the following to the top of the file:
///<reference path="./typings/globals/node/index.d.ts" />
import {Request} from "~express/lib/express";
But the second line produces an error:
TS2307: Cannot fine module '~express/lib/express'
I've installed the typings of express, so I actually didn't wrote those two lines by myself, but WebStorm auto generated them by clicking "alt + enter", so I would expect it to work. Unfortunately I get that error.
What am I doing wrong?
Upvotes: 0
Views: 861
Reputation: 11895
The problem was that the script reference path was to "node" rather than to "express":
///<reference path="./typings/globals/node/index.d.ts" />
So this has fixed it:
///<reference path="./typings/modules/express/index.d.ts" />
Upvotes: 0
Reputation: 451
I think you should try this line
import * as express from "express";
it was taken from http://brianflove.com/2016/03/29/typescript-express-node-js/
hope it helps you.
Upvotes: 2