Skip to content

description of radix argument in parseInt calls string "numString", but parseInt header calls it "s" #42741

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

Closed
hamirmahal opened this issue Feb 10, 2021 · 0 comments Β· Fixed by #42756
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Milestone

Comments

@hamirmahal
Copy link

Bug Report

πŸ”Ž Search Terms

numString

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about numString.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const anExampleVariable = parseInt("343", 2);

πŸ™ Actual behavior

When calling parseInt and filling in its optional second parameter, it says,

parseInt(s: string, radix?: number | undefined): number
A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.


Converts a string to an integer.

and the variable name in the description of the radix argument, numString, does not match the parameter name of the string in parseInt's function header, s.

Screen Shot 2021-02-10 at 9 51 32 AM

πŸ™‚ Expected behavior

For consistency, I think the variable name in the description for the radix parameter, numString, should match the parameter variable name in parseInt's function header, s. Two possible solutions are renaming parseInt's first, string parameter variable name from s to numString, or renaming the variable in the radix parameter argument's description from numString to s.

If this is something we can change, I would like to contribute the fix for it.

I realize this issue isn't really severe at all: on a scale from 1 to 10, where 1 is hardly severe at all, and 10 is very severe, this would be a 1. I just point it out because it might be helpful to use the same name to refer to the same variable, instead of calling it s in the function header and numString in the description of the radix argument.

I did a bit of research before creating this issue and saw that MDN calls parseInt's string parameter string, and refers to that parameter in the description of the radix argument as string, being consistent.

I also looked at the ECMAScript 2015 specification for parseInt, but they don't refer to the string parameter from a description of the radix parameter, so the naming inconsistency issue I'm mentioning here isn't present there.

Similarly, an annotated ES5 specification for parseInt doesn't have a naming inconsistency for the first, string argument of parseInt that I noticed.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Feb 10, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 10, 2021
@DanielRosenwasser DanielRosenwasser added Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants