Microsoft/TypeScript

Docs of `charCodeAt` and `codePointAt` are flipped

Open

#49 561 ouverte le 15 juin 2022

Voir sur GitHub
 (8 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: lib.d.tsHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

Bug Report

Docs of charCodeAt and codePointAt are flipped. Described in MDN, the codePointAt returns Unicode code point, and charCodeAt returns UTF16 char code, however in JSDoc string of Typescript they are flipped.

How it is

https://github.com/microsoft/TypeScript/blob/89d05f7131b233c4482aaba5c15ad289f26173b4/lib/lib.es2015.core.d.ts#L401-L408

https://github.com/microsoft/TypeScript/blob/89d05f7131b233c4482aaba5c15ad289f26173b4/lib/lib.es5.d.ts#L404-L408

How it should be

The codePointAt() method returns a non-negative integer that is the Unicode code point value at the given position. Note that this function does not give the nth code point in a string, but the code point starting at the specified string index. Docs

The charCodeAt() method returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index. Docs

Guide contributeur