We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 [email protected] /Users/zixia/git/wechaty └── @types/[email protected] $ ./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
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.
@types/ws
@types/express
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
The text was updated successfully, but these errors were encountered:
You need to explicitly specify "node" module resolution strategy, as the default for ES6 target is "classic". E.g.
$ ./node_modules/.bin/tsc --target es6 --moduleResolution node t.ts
Sorry, something went wrong.
Thanks @jonrimmer. this is the correct workaround for [email protected].
[email protected]
The issue has been fixed in typescript@next and should be part of [email protected]. Please see #11103 for more details.
typescript@next
@jonrimmer thanks! this cost my serval hours to study... and had not found any solution until read from your post.
why tsc not to search @types by default?
as a mentioned, it is a bug, reproted in #11103, and fixed. sorry about the confusion.
passing --moduleResolution node would address the issue.
--moduleResolution node
@mhegazy got it. thanks!
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version:
2.0.3
Code
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
The text was updated successfully, but these errors were encountered: