Document indexOf return value when not found#60569
Document indexOf return value when not found#60569Pascal-So wants to merge 3 commits intomicrosoft:mainfrom
Conversation
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
|
@microsoft-github-policy-service agree |
|
note that i didn't get the tests to pass. i experimented a bit locally and to me it seemed like the process is to copy over the generated files as the new baseline references, but even after doing that the tests still didn't pass. does anyone know how i get the test runner to print the actual diffs rather than just fail the test? |
|
See https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#managing-the-baselines You'd just need to run the tests and then run the "baseline-accept" task. |
|
@jakebailey ah, thanks for the hint! turns out my problem was that my editor changed some crlf's to lf when I tried to manually copy over the updated files before :D |
fixes #60570
The documentation for
indexOfon arrays already mentioned that the method returns -1 when the value is not found:But for strings, this information was missing thus far:
Of course the user would have been able to puzzle this together by seeing that the return type is just
number, not something likenumber | undefined, thus allowing them to figure out that the sentinel value probably must be -1. Nevertheless, having to stop and think about this is unnecessary friction for people who don't remember this fact by heart, for example people who jump between programming languages a lot.I also noticed that the same information was missing for all the
TypedArrays, so I went ahead and extended the docs there as well.