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

[node/readline] Expose 'line' & 'cursor' properties #40513

Merged

Conversation

Js-Brecht
Copy link
Contributor

The current "line" and "cursor" states are often necessary when developing applications that use readline for prompts.

While the properties should be accessible, they are also meant to be used internally, and modifying them could result in unexpected behavior when drawing, which is why they are readonly. They can be modified safely, but cursor would have to be modified in tandem with line. IMO, it's better to make them readonly, so overwriting them will be an explicit effort; that way whoever does it is fully aware of what they are doing.

See nodejs/node#30347


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).

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: Expose readline.Interface "line", "cursor", "getCursorPos" nodejs/node#30347
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.

@typescript-bot typescript-bot added this to Waiting for Reviewers in Pull Request Status Board Nov 20, 2019
@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Nov 20, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 20, 2019

@Js-Brecht Thank you for submitting this PR!

🔔 @microsoft @DefinitelyTyped @jkomyno @a-tarasyuk @alvis @r3nya @btoueg @BrunoScheufler @smac89 @tellnes @Touffy @DeividasBakanas @eyqs @Flarna @Hannes-Magnusson-CK @KSXGitHub @hoo29 @kjin @ajafff @islishude @mwiktorczyk @mohsen1 @n-e @octo-sniffle @galkin @parambirs @eps1lon @SimonSchick @ThomasdenH @WilcoBakker @wwwy3y3 @ZaneHannanAU @samuela @kuehlein @j-oliveras @bhongy @chyzwar @trivikr @nguymin4 @yoursunny @qwelias @jeremiergz - 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.

@typescript-bot typescript-bot moved this from Waiting for Reviewers to Needs Author Attention in Pull Request Status Board Nov 20, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 20, 2019

@Js-Brecht 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!

@Flarna
Copy link
Contributor

Flarna commented Nov 20, 2019

It's usually not needed to updated typings for EOL versions of node (9, 11).

Copy link
Contributor

@galkin galkin left a comment

Choose a reason for hiding this comment

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

Looks good for me

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Nov 20, 2019
@Js-Brecht
Copy link
Contributor Author

@Flarna Is it EOL for 9-11 already? I just figured that since they are valid properties for those versions as well, that they should be typed. Or are you saying they are EOL for @types/node (I was thinking node itself), so those changes won't get published anyway?


Anybody have an idea why the DefinitelyTyped.BenchmarkPR is failing? It appears to be an issue with the v12 changes, but I'm not sure if I actually have any control over the issue: not being able to find a lock file seems like an internal problem 😕

2019-11-20T00:21:57.3155921Z Comparing node/v12 because it changed...
2019-11-20T00:21:57.3157374Z 
2019-11-20T00:21:57.3157893Z 
2019-11-20T00:21:57.6322302Z No comparable benchmark for node/v12. Checking out master and running one...
2019-11-20T00:21:58.3418386Z Parsing definitions...
2019-11-20T00:21:58.5600708Z Found 6222 packages.
2019-11-20T00:21:58.5602296Z Parsing in parallel...
2019-11-20T00:28:53.0657250Z 0.7% done...
2019-11-20T00:33:53.6105395Z 1.3% done...
2019-11-20T00:38:54.4625154Z 2.0% done...
2019-11-20T00:43:54.6796649Z 2.7% done...
2019-11-20T00:48:55.2633369Z 3.4% done...
2019-11-20T00:53:56.0081457Z 4.1% done...
2019-11-20T00:58:56.3525277Z 4.8% done...
2019-11-20T01:03:57.2109218Z 5.5% done...
2019-11-20T01:08:58.1184355Z 6.2% done...
2019-11-20T01:13:58.4209360Z 6.8% done...
2019-11-20T01:18:58.8171726Z 7.5% done...
2019-11-20T01:24:00.1149405Z Parsing definitions...
2019-11-20T01:24:00.3571551Z Found 6222 packages.
2019-11-20T01:24:00.3572840Z Parsing in parallel...
2019-11-20T01:25:28.3442045Z Error: Error: Command failed: npm install --ignore-scripts --no-shrinkwrap --no-package-lock --no-bin-links
2019-11-20T01:25:28.3443372Z npm ERR! code ENOENT
2019-11-20T01:25:28.3444274Z npm ERR! syscall lchown
2019-11-20T01:25:28.3445186Z npm ERR! path /home/vsts/.npm/_locks/staging-4f31c809bbe9df41.lock
2019-11-20T01:25:28.3445966Z npm ERR! errno -2
2019-11-20T01:25:28.3446549Z npm ERR! enoent ENOENT: no such file or directory, lchown '/home/vsts/.npm/_locks/staging-4f31c809bbe9df41.lock'
2019-11-20T01:25:28.3446808Z npm ERR! enoent This is related to npm not being able to find a file.
2019-11-20T01:25:28.3446987Z npm ERR! enoent 

It was successful at one point. I recall it failed after I originally submitted the PR, then I added the v11 test, and it was successful when it ran again. I pushed the v9 change, and it failed again, the same way as the first time. These changes are so innocuous, I don't know what is breaking it.

@SimonSchick
Copy link
Contributor

@Js-Brecht We avoid updating EOL versions as the node team itself doesn't support them either, 10 is LTS (odd vs. even).
The install is a known issue https://github.com/microsoft/types-publisher/issues/707

@Js-Brecht
Copy link
Contributor Author

@SimonSchick Ahh, I see. I should have looked at https://nodejs.org/en/about/releases/. I will revert the changes to v9 and v11

@typescript-bot typescript-bot moved this from Needs Author Attention to Check and Merge in Pull Request Status Board Nov 20, 2019
@typescript-bot
Copy link
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!

@SimonSchick
Copy link
Contributor

@Js-Brecht so I can see these properties currently exist but are not documented.
The node discussion seems to imply they'd rather expose the getCursorPos method rather than making those properties public.
Can you elaborate?

@Js-Brecht
Copy link
Contributor Author

@SimonSchick Sure. The plan was to expose line, cursor and getCursorPos. They mentioned that the line and cursor properties were just never documented (nodejs/node#30347 (comment)), but didn't seem to care about them being exposed. They've asked that I also submit a PR documenting them (nodejs/node#30347 (comment)). That will be the next one I open for this particular endeavor.

I could ask for them to explicitly approve making these two properties public.

getCursorPos is going to be a separate PR, since it's going to involve promoting _getCursorPos() to public API. That has to be implemented, and approved by the node team before I write types for it.

@Js-Brecht
Copy link
Contributor Author

Or if you'd like to wait until the documentation PR is approved, I'd be okay with that

@typescript-bot typescript-bot moved this from Check and Merge to Needs Author Attention in Pull Request Status Board Nov 20, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 20, 2019

@Js-Brecht 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!

Js-Brecht added a commit to Js-Brecht/node that referenced this pull request Nov 23, 2019
Documents the existence and purpose of the `line` and `cursor`
properties.  `line` can be used for reading the current input value
during runtime, if reading from a TTY stream.  Both properties are
necessary when developing a custom CLI input process using `readline`
as a backend.

Refs: nodejs#30347
Refs: DefinitelyTyped/DefinitelyTyped#40513
@typescript-bot
Copy link
Contributor

@Js-Brecht 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.

@Js-Brecht
Copy link
Contributor Author

Finally had a moment to file my PR with nodejs. See nodejs/node#30667.

@SimonSchick Is it possible to get @typescript-bot to hold off until that PR gets reviewed and accepted/rejected?

@Js-Brecht
Copy link
Contributor Author

targos pushed a commit to nodejs/node that referenced this pull request Dec 9, 2019
Documents the existence and purpose of the `line` and `cursor`
properties.  `line` can be used for reading the current input value
during runtime, if reading from a TTY stream.  Both properties are
necessary when developing a custom CLI input process using `readline`
as a backend.

Refs: #30347
Refs: DefinitelyTyped/DefinitelyTyped#40513

PR-URL: #30667
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@amcasey amcasey reopened this Dec 9, 2019
@amcasey
Copy link
Contributor

amcasey commented Dec 9, 2019

@Js-Brecht Reopened. Good to go?

@typescript-bot typescript-bot added this to Needs Author Attention in Pull Request Status Board Dec 9, 2019
Pull Request Status Board automation moved this from Needs Author Attention to Done Dec 9, 2019
@Js-Brecht
Copy link
Contributor Author

Yes, it is good to go

@amcasey amcasey reopened this Dec 9, 2019
@amcasey
Copy link
Contributor

amcasey commented Dec 9, 2019

I don't know what's up with the bot, but I'll merge it once CI completes.

@typescript-bot typescript-bot moved this from Done to Check and Merge in Pull Request Status Board Dec 9, 2019
@typescript-bot typescript-bot added Other Approved This PR was reviewed and signed-off by a community member. Merge:Express and removed Abandoned This PR had no activity for a long time, and is considered abandoned labels Dec 9, 2019
@typescript-bot typescript-bot moved this from Check and Merge to Needs Author Attention in Pull Request Status Board Dec 9, 2019
@typescript-bot typescript-bot added The Travis CI build failed Abandoned This PR had no activity for a long time, and is considered abandoned and removed Merge:Express labels Dec 9, 2019
Pull Request Status Board automation moved this from Needs Author Attention to Done Dec 9, 2019
@amcasey amcasey merged commit 141ff98 into DefinitelyTyped:master Dec 9, 2019
@amcasey
Copy link
Contributor

amcasey commented Dec 9, 2019

Note to future readers - the Travis build passed on re-run.

@typescript-bot
Copy link
Contributor

I just published @types/node@12.12.16 to npm.

@typescript-bot
Copy link
Contributor

I just published @types/node@10.17.8 to npm.

targos pushed a commit to nodejs/node that referenced this pull request Jan 14, 2020
Documents the existence and purpose of the `line` and `cursor`
properties.  `line` can be used for reading the current input value
during runtime, if reading from a TTY stream.  Both properties are
necessary when developing a custom CLI input process using `readline`
as a backend.

Refs: #30347
Refs: DefinitelyTyped/DefinitelyTyped#40513

PR-URL: #30667
Reviewed-By: Anna Henningsen <anna@addaleax.net>
BethGriggs pushed a commit to nodejs/node that referenced this pull request Feb 6, 2020
Documents the existence and purpose of the `line` and `cursor`
properties.  `line` can be used for reading the current input value
during runtime, if reading from a TTY stream.  Both properties are
necessary when developing a custom CLI input process using `readline`
as a backend.

Refs: #30347
Refs: DefinitelyTyped/DefinitelyTyped#40513

PR-URL: #30667
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Abandoned This PR had no activity for a long time, and is considered abandoned Other Approved This PR was reviewed and signed-off by a community member. Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Popular package This PR affects a popular package (as counted by NPM download counts). Revision needed This PR needs code changes before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants