Skip to content
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

lib.es6.d.ts declares console.debug() #11751

Closed
BurtHarris opened this issue Oct 20, 2016 · 8 comments
Closed

lib.es6.d.ts declares console.debug() #11751

BurtHarris opened this issue Oct 20, 2016 · 8 comments

Comments

@BurtHarris
Copy link

BurtHarris commented Oct 20, 2016

I'm not sure why lib.es6.d.ts defines method debug on interface Console. I don't find evidence that it's specified by the ECMA standard, or commonly implemented. It looks like console.debug may be a Microsoft (and Chrome)-specific extension, that functions the same as console.log per both MSDN and Chrome docs.. Compare this with Node console documentation.

TypeScript Version: 2.0.3

Code

console.debug("asdf");

Expected behavior:
Shouldn't this generate a TypeScript compiler error?

Actual behavior:
When building for ES6 target, seems to be accepted, but will generate a runtime error on Node.js.

Note
console.debug() is defined in the current WHATWG console document, but the definition there clearly indicates it is duplicative of console.log(),

@BurtHarris BurtHarris changed the title lib.es6.d.ts declares console.debug() etc. lib.es6.d.ts declares console.debug() Oct 20, 2016
@domenic
Copy link

domenic commented Oct 20, 2016

console.log is part of the standard; it's not a browser-specific extension.

@BurtHarris
Copy link
Author

Its not part of the ECMA standard, as would be implied by its inclusion in this particular definition file, it is just par of the "living" whatwg document.

@domenic
Copy link

domenic commented Oct 20, 2016

Sure, maybe it should be in a different file, but it's part of the Console Standard, which is the only normative definition of console. So this isn't a concern specific to debug, I guess; maybe you should retitle your bug to reflect wanting to create a separate definition file for the Console Standard.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 20, 2016

The console definition is included with the DOM definition. since you are using node, you do not need either. so for node specify --lib es6 (as opposed tot he default --lib es6,dom) and that should avoid adding the console in your global scope.

@BurtHarris
Copy link
Author

BurtHarris commented Oct 20, 2016

Thanks @mhegazy. Adding "lib": ["es6"], to my tsconfig.json flags it and caught a few other interesting potential defects. Of particular interest were bare references to name and toString() that need to be qualified!

I would have thought that specifying "target": "es2015", and "types": [ "node" ], would have been enough to let TypeScript know the environment, but I'm fine with this as a workaround.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 20, 2016

We have an issue to support --lib node, which basically takes care of this issue as well as needing to specify "types": [ "node" ] and installing @types\node in the first place. See #9466. The main issue is versions, and introducing yet another way to get to node definitions.

@falsandtru
Copy link
Contributor

I want to use console function definitions with lib.console.d.ts and --lib console option.

@RyanCavanaugh RyanCavanaugh removed the Needs Investigation This issue needs a team member to investigate its status. label Sep 16, 2019
@RyanCavanaugh
Copy link
Member

node supports console.debug now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants