Skip to content

"error TS2307: Cannot find module" when using @types/ws with typescript 2.0 #11491

@huan

Description

@huan

TypeScript Version:

2.0.3

Code

// A *self-contained* demonstration of the problem follows...
import * as WebSocket from 'ws'
const ws = new WebSocket('https://api.wechaty.io')
console.log('ws')
$ npm install @types/ws
wechaty@0.4.0 /Users/zixia/git/wechaty
└── @types/ws@0.0.34 

$ ./node_modules/.bin/tsc --target es6 t.ts
t.ts(1,28): error TS2307: Cannot find module 'ws'.

Expected behavior:

should found the type defination of ws

Actual behavior:

TS2307 error

It's not like the problem from @types/ws, because if i use another module like @types/express, will be the same error.

BTW: if i run without es6 target, it will ok, but I can't use async/await

$ ./node_modules/.bin/tsc t.ts # will be ok

http://stackoverflow.com/questions/39960436/error-ts2307-cannot-find-module-when-using-types-ws-with-typescript-2-0

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions