-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
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
Node projects with --lib es6: cannot find name 'console' #9545
Comments
Looks like a definition bug in nose.d.ts |
PR on DefinitelyTyped: |
How to resolve this problem? |
@frogcjn if you get your node typings using |
thanks @yortus |
This seems to have caused this bug: |
tsconfig , |
thanks @gatspy |
thanks @gatspy ,it works! |
@gatspy thanks |
TypeScript Version: nightly (2.0.0-dev.20160706)
Code
Expected behavior:
Compiles without errors
Actual behavior:
console
is not definedMore Info:
node.d.ts
does not contain a definition for the globalconsole
instance or for theConsole
class. References toconsole
are resolved against the definitions fromlib.dom.d.ts
. But now with the--lib
option, Node projects can opt out of the ambient DOM typings. That brings up the problem thatconsole
is not defined.It's not as simple as just copying the ambient
console
andConsole
definitions fromlib.dom.d.ts
intonode.d.ts
, because in browsers theConsole
constructor is globally available but in Node it is not. 'Hiding'Console
under theNodeJS
namepace innode.d.ts
wont work either because then projects that don't use the--lib
option will get conflicting DOM and Node definitions and will see the errorTS2403: Subsequent variable declarations must have the same type. Variable 'console' must be of type 'Console', but here has type 'Console'.
I'm testing out changes to
node.d.ts
that will work both with and without--lib
, and will submit a PR to DefinitelyTyped if I can get it working.The text was updated successfully, but these errors were encountered: