Sing
Sing

Reputation: 4052

How to reference @types/module in typescript?

After I install module like @types/express via npm, how do I reference it in typescript?

I have try followings :

  1. /// <reference path="../node_modules/@types/express/index.d.ts" /> still give me can not find module 'express' error

  2. import * as express from '@types/express'; can pass the typescript compilation, but after compile will be require('@types/express') which should be require('express') instead.

Upvotes: 2

Views: 3611

Answers (1)

toskv
toskv

Reputation: 31600

That is a TypeScript 2.0+ plus. It will not work with versions earlier than that.

As of now 2.0 is still in beta but there is a release candidate available as the typescript@rc version. To install i run:

npm install -g typescript@rc

The nightly build is also available as typescript@next:

npm install -g typescript@next

Upvotes: 1

Related Questions