Skip to content

@types/node: Add missing methods to Console, plus docs#25327

Merged
2 commits merged intoDefinitelyTyped:masterfrom
thw0rted:node-console
May 3, 2018
Merged

@types/node: Add missing methods to Console, plus docs#25327
2 commits merged intoDefinitelyTyped:masterfrom
thw0rted:node-console

Conversation

@thw0rted
Copy link
Copy Markdown
Contributor

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes
    node 9.X, node 10.X
  • Increase the version number in the header if appropriate. (N/A)

@thw0rted
Copy link
Copy Markdown
Contributor Author

If there's a better way to handle "this method only works with --inspect" I am open to suggestions.

@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Apr 26, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 26, 2018

@thw0rted Thank you for submitting this PR!

🔔 @parambirs @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @DeividasBakanas @kjin @alvis @OliverJAsh @eps1lon @Hannes-Magnusson-CK @jkomyno @ajafff @hoo29 @n-e - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

Comment thread types/node/index.d.ts
/**
* The `console.dirxml()` function is an alias for {@link console.log()}.
*/
dirxml(...data: any[]): void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a difference in the type definition of dirxml to log if one is just an alias of the other?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is based on the Node docs, which say that the method signature is ...data <any>, and that it "calls console.log() passing it the arguments received". The official spec agrees with Node's definition, even though the MDN page says it's "non-standard" and only takes exactly one argument. Of course, logically foo(...everything: any[]) works identically to foo(first?: any, ...others: any[]) (from the caller's perspective) so it's kind of academic.

All that to say: I copied it from other similar methods (like debug) and probably should have used the original docs from Node,

This method calls console.log() passing it the arguments received. Please note that this method does not produce any XML formatting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found following in NodeJS Source:

Console.prototype.info = Console.prototype.log;
Console.prototype.dirxml = Console.prototype.log;```
So seems there is really no difference between them.

But you are right, for the user it's don't care which variant is used here in the typings.

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. The Travis CI build failed and removed Awaiting reviewer feedback labels Apr 27, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 27, 2018

@thw0rted The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@thw0rted
Copy link
Copy Markdown
Contributor Author

Looks like your Travis is jacked, the failures are unrelated to these changes. Who can address?

@thw0rted
Copy link
Copy Markdown
Contributor Author

Hey @Flarna and others watching, I have a DT / node question and figured it probably wasn't worth opening a new issue / PR until I understand why things are the way they are. For a long time, Node's typings have included a NodeBuffer interface, marked @deprecated, which the actual Buffer interface extends without adding anything. I don't think NodeBuffer is a real interface in Node proper and isn't referenced anywhere in the current (v9 / v10) docs, even under Deprecated APIs. Is this just a placeholder for some reason? Is there any reason not to just rename NodeBuffer to Buffer directly and remove the deprecation decorator?

If my guess is right, I'll make a new PR (maybe after this one merges successfully?) that does this.

@typescript-bot
Copy link
Copy Markdown
Contributor

@thw0rted I haven't seen anything from you in a while and this PR currently has problems that prevent it from being merged. The PR will be closed tomorrow if there aren't new commits to fix the issues.

@typescript-bot
Copy link
Copy Markdown
Contributor

A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

@ghost ghost merged commit 6372e41 into DefinitelyTyped:master May 3, 2018
@thw0rted thw0rted deleted the node-console branch May 8, 2018 08:13
KSXGitHub pushed a commit to KSXGitHub/DefinitelyTyped that referenced this pull request May 12, 2018
…ed#25327)

* Add missing methods to node Console, plus docs

* Update Node console dirxml per review comment
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants