GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: improve hideStackFrames intellisense by anonrig · Pull Request #44181 · nodejs/node

Conversation

@anonrig

@anonrig anonrig commented Aug 8, 2022

Copy link
Copy Markdown
Member

This is a draft pull request to improve the developer experience by fixing internal function's JSDoc declarations. I wanted to receive some feedback before investing time on this.

Previously, all functions that uses hideStackFrames was invalidly typed and was shown as a warning in IDEs (On WebStorm and Sublime).

I wanted to introduce T is boolean kind of type guards into the functions but could not find a solution for functions that does not return any boolean, but throws an error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss and shakogegia reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@anonrig
lib: improve hideStackFrames intellisense
16d2a85
@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originating in Node.js core. needs-ci PRs that need a full CI run. labels Aug 8, 2022
@anonrig
anonrig marked this pull request as ready for review August 8, 2022 20:43
@aduh95

aduh95 commented Aug 16, 2022

Copy link
Copy Markdown
Contributor

Previously, all functions that uses hideStackFrames was invalidly typed and was shown as a warning in IDEs (On WebStorm and Sublime).

Why do you say it was invalid? What warning do you see?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Aug 16, 2022

Copy link
Copy Markdown
Member

I wanted to introduce T is boolean kind of type guards into the functions but could not find a solution for functions that does not return any boolean, but throws an error.

In TypeScript, the return type for this kind of functions is asserts value is SomeType.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Aug 16, 2022

Copy link
Copy Markdown
Member Author

Why do you say it was invalid? What warning do you see?

@aduh95 The previous error for all functions that use hideStackFrames was Invalid number of arguments

Screen Shot 2022-08-16 at 8 19 44 AM

In TypeScript, the return type for this kind of functions is asserts value is SomeType.

@targos Most of our validate functions does not return a value, but throw's an error if assertion fails. In that scenario, T is SomeType type guard is not the correct approach. Do you know a way to assert the function input type without a return value?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Aug 16, 2022

Copy link
Copy Markdown
Member

@anonrig Note the asserts keyword.

anonrig reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Aug 16, 2022

Copy link
Copy Markdown
Member Author

Changing validateInteger jsdoc to the following improves the autocompletion.

/**
 * @function validateInteger
 * @param {never} value
 * @param {string} name
 * @param {number=} min
 * @param {number=} max
 * @returns {asserts value is number}
 */

Screen Shot 2022-08-16 at 8 39 20 AM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95

aduh95 commented Aug 16, 2022

Copy link
Copy Markdown
Contributor

Can we not use the Closure Compiler syntax? We should be using JSDoc instead:

/**
 * @callback myCallback
 * @param {number} mandatory
 * @param {number} [optional]
 */

/** @type {myCallback} */
var cb;
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Aug 16, 2022

Copy link
Copy Markdown
Member Author

I did not really quite understand your point since JSDoc lacks certain functionality. JSDoc does not have @template syntax. How can we achieve the same thing with only JSDoc?

/**
 * @function validateOneOf
 * @template T
 * @param {T} value
 * @param {string} name
 * @param {T[]} oneOf
 */
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Aug 16, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
lib: update validator jdoc declarations
21e8903
@anonrig
anonrig force-pushed the improve/jsdoc branch from 06c82df to 21e8903 Compare August 16, 2022 15:30
anonrig added 3 commits August 16, 2022 11:31
@anonrig
lib: add missing null default value to validateObject
7364ab9
@anonrig
lib: add missing return due to jsdoc/require-returns-check
a999fa6
@anonrig
lib: replace functions with callbacks on jsdoc
3b6d180
aduh95
aduh95 reviewed Aug 17, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Aug 17, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Aug 17, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
lib: update according to feedback
4c4c46a
@anonrig
anonrig force-pushed the improve/jsdoc branch from c3f0e7f to 4c4c46a Compare August 17, 2022 14:00
@anonrig

anonrig commented Aug 17, 2022

Copy link
Copy Markdown
Member Author

Thanks for the review @aduh95. I've fixed them all.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Aug 17, 2022
View reviewed changes

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM, there's just one parameter that should be documented as optional

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Aug 17, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
lib: add missing optional jsdoc to validateSignalName
ee0ab2a
@anonrig
anonrig force-pushed the improve/jsdoc branch from 5abe5d8 to ee0ab2a Compare August 17, 2022 14:04
aduh95
aduh95 reviewed Aug 17, 2022
View reviewed changes

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sorry for the back and forth, I still have some questions/suggestions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

anonrig added 2 commits August 17, 2022 10:12
@anonrig
lib: fix wrong jsdoc for validateUint32
62fde49
@anonrig
lib: suppress eslint rule for jsdoc
b47611f
aduh95
aduh95 approved these changes Aug 17, 2022
View reviewed changes

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, LGTM!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig and tony-go reacted with hooray emoji
All reactions
  • 🎉 2 reactions
@aduh95 aduh95 added author ready PRs with CI started, the required approvals, and no outstanding review comments. and removed needs-ci PRs that need a full CI run. labels Aug 17, 2022
targos
targos reviewed Aug 17, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
lib: make number validation input any
49db869
targos
targos approved these changes Aug 17, 2022
View reviewed changes
Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/validators.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
lib: add missing assertions
0c9fbc5
@anonrig
anonrig force-pushed the improve/jsdoc branch from 500ed90 to 0c9fbc5 Compare August 17, 2022 15:13
targos
targos approved these changes Aug 17, 2022
View reviewed changes
@aduh95 aduh95 added the typings Issues and PRs related to internal TypeScript declarations. label Aug 17, 2022
@aduh95
aduh95 merged commit ab9b590 into nodejs:main Aug 17, 2022
@aduh95

aduh95 commented Aug 17, 2022

Copy link
Copy Markdown
Contributor

Landed in ab9b590, thanks for the contribution 🎉

anonrig reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ruyadorno pushed a commit that referenced this pull request Aug 23, 2022
@anonrig @ruyadorno
typings: add JSDoc for internal/validators
2efce0f
PR-URL: #44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Aug 23, 2022
v18.8.0 release proposal #44353
Merged
juanarbol pushed a commit that referenced this pull request Oct 3, 2022
@anonrig @juanarbol
typings: add JSDoc for internal/validators
f3fd4e1
PR-URL: #44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
@juanarbol juanarbol mentioned this pull request Oct 4, 2022
V16.18.0 proposal #44886
Merged
juanarbol pushed a commit that referenced this pull request Oct 4, 2022
@anonrig @juanarbol
typings: add JSDoc for internal/validators
76d10c0
PR-URL: #44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
juanarbol pushed a commit that referenced this pull request Oct 7, 2022
@anonrig @juanarbol
typings: add JSDoc for internal/validators
0788f80
PR-URL: #44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
juanarbol pushed a commit that referenced this pull request Oct 11, 2022
@anonrig @juanarbol
typings: add JSDoc for internal/validators
a08cdea
PR-URL: #44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Jan 3, 2023
@anonrig @guangwong
typings: add JSDoc for internal/validators
fc26cb4
PR-URL: nodejs/node#44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Jan 3, 2023
@anonrig @guangwong
typings: add JSDoc for internal/validators
df11d14
PR-URL: nodejs/node#44181
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aduh95 aduh95 aduh95 approved these changes
+1 more reviewer
@targos targos targos approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. errors Issues and PRs related to JavaScript errors originating in Node.js core. typings Issues and PRs related to internal TypeScript declarations.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@anonrig @aduh95 @targos @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.