Skip to content

Commit cfa4f7b

Browse files
authored
String.charCodeAt should return int (#7864)
* String.charCodeAt should return int * CHANGELOG
1 parent 8902a27 commit cfa4f7b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#### :boom: Breaking Change
1616

17+
- Fix return type of `String.charCodeAt`. https://github.com/rescript-lang/rescript/pull/7864
18+
1719
#### :eyeglasses: Spec Compliance
1820

1921
#### :rocket: New Feature

packages/@rescript/runtime/Stdlib_String.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ external compare: (string, string) => Stdlib_Ordering.t = "%compare"
1717
@get_index external getUnsafe: (string, int) => string = ""
1818
@send external charAt: (string, int) => string = "charAt"
1919

20-
@send external charCodeAt: (string, int) => float = "charCodeAt"
20+
@send external charCodeAt: (string, int) => int = "charCodeAt"
2121
@send external codePointAt: (string, int) => option<int> = "codePointAt"
2222

2323
@send external concat: (string, string) => string = "concat"

packages/@rescript/runtime/Stdlib_String.resi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ See [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScrip
220220
## Examples
221221
222222
```rescript
223-
String.charCodeAt(`😺`, 0) == 0xd83d->Int.toFloat
223+
String.charCodeAt(`😺`, 0) == 0xd83d
224224
String.codePointAt(`😺`, 0) == Some(0x1f63a)
225225
```
226226
*/
227227
@send
228-
external charCodeAt: (string, int) => float = "charCodeAt"
228+
external charCodeAt: (string, int) => int = "charCodeAt"
229229

230230
/**
231231
`codePointAt(str, index)` returns the code point at position `index` within

0 commit comments

Comments
 (0)