Skip to content

Commit a731a41

Browse files
committed
more migrations
1 parent 03423e0 commit a731a41

22 files changed

+535
-11
lines changed

packages/@rescript/runtime/Js_array.res

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ type t<'a> = array<'a>
4242
/**
4343
A type used to describe JavaScript objects that are like an array or are iterable.
4444
*/
45+
@deprecated({
46+
reason: "Use `Array.arrayLike` instead.",
47+
migrate: %replace.type(: Array.arrayLike),
48+
})
4549
type array_like<'a> = Js_array2.array_like<'a>
4650

4751
/* commented out until bs has a plan for iterators
@@ -59,6 +63,10 @@ Js.Array.from(strArr) == ["a", "b", "c", "d"]
5963
```
6064
*/
6165
@val
66+
@deprecated({
67+
reason: "Use `Array.fromArrayLike` instead.",
68+
migrate: Array.fromArrayLike(),
69+
})
6270
external from: array_like<'a> => array<'a> = "Array.from"
6371

6472
/* ES2015 */
@@ -78,11 +86,20 @@ Js.Array.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0]
7886
```
7987
*/
8088
@val
89+
@deprecated({
90+
reason: "Use `Array.fromArrayLikeWithMap` instead.",
91+
migrate: Array.fromArrayLikeWithMap(),
92+
})
8193
external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from"
8294

8395
/* ES2015 */
8496

85-
@val external isArray: 'a => bool = "Array.isArray"
97+
@deprecated({
98+
reason: "Use `Array.isArray` instead.",
99+
migrate: Array.isArray(),
100+
})
101+
@val
102+
external isArray: 'a => bool = "Array.isArray"
86103
/* ES2015 */
87104
/*
88105
Returns `true` if its argument is an array; `false` otherwise. This is a
@@ -101,6 +118,10 @@ Js.Array.isArray("abcd") == false
101118
/**
102119
Returns the number of elements in the array. See [`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) on MDN.
103120
*/
121+
@deprecated({
122+
reason: "Use `Array.length` instead.",
123+
migrate: Array.length(),
124+
})
104125
external length: array<'a> => int = "%array_length"
105126

106127
/* Mutator functions */
@@ -222,6 +243,10 @@ let empty: array<int> = []
222243
Js.Array.pop(empty) == None
223244
```
224245
*/
246+
@deprecated({
247+
reason: "Use `Array.pop` instead.",
248+
migrate: Array.pop(),
249+
})
225250
@send
226251
external pop: t<'a> => option<'a> = "pop"
227252

@@ -266,6 +291,10 @@ Js.Array.reverseInPlace(arr) == ["cat", "bee", "ant"]
266291
arr == ["cat", "bee", "ant"]
267292
```
268293
*/
294+
@deprecated({
295+
reason: "Use `Array.reverse` instead.",
296+
migrate: Array.reverse(),
297+
})
269298
@send
270299
external reverseInPlace: t<'a> => 'this = "reverse"
271300

@@ -283,6 +312,10 @@ let empty: array<int> = []
283312
Js.Array.shift(empty) == None
284313
```
285314
*/
315+
@deprecated({
316+
reason: "Use `Array.shift` instead.",
317+
migrate: Array.shift(),
318+
})
286319
@send
287320
external shift: t<'a> => option<'a> = "shift"
288321

@@ -301,6 +334,9 @@ Js.Array.sortInPlace(numbers) == [1, 10, 2, 20, 3, 30]
301334
numbers == [1, 10, 2, 20, 3, 30]
302335
```
303336
*/
337+
@deprecated(
338+
"This has been deprecated and will be removed in v13. Use functions from the `Array` module instead."
339+
)
304340
@send
305341
external sortInPlace: t<'a> => 'this = "sort"
306342

@@ -531,7 +567,7 @@ Js.Array.indexOfFrom("b", ~from=2, ["a", "b", "a", "c", "a"]) == -1
531567
external indexOfFrom: (t<'a>, 'a, ~from: int) => int = "indexOf"
532568
let indexOfFrom = (arg1, ~from, obj) => indexOfFrom(obj, arg1, ~from)
533569

534-
@send @deprecated("please use joinWith instead")
570+
@send @deprecated({reason: "Use `Array.join` instead.", migrate: Array.join()})
535571
external join: t<'a> => string = "join"
536572

537573
/**
@@ -615,6 +651,10 @@ Returns a copy of the entire array. Same as `Js.Array.Slice(~start=0,
615651
[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
616652
on MDN.
617653
*/
654+
@deprecated({
655+
reason: "Use `Array.copy` instead.",
656+
migrate: Array.copy(),
657+
})
618658
@send
619659
external copy: t<'a> => 'this = "slice"
620660

@@ -646,6 +686,10 @@ Js.Array.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8"
646686
Js.Array.toString(["a", "b", "c"]) == "a,b,c"
647687
```
648688
*/
689+
@deprecated({
690+
reason: "Use `Array.toString` instead.",
691+
migrate: Array.toString(),
692+
})
649693
@send
650694
external toString: t<'a> => string = "toString"
651695

@@ -665,6 +709,10 @@ Js.Array.toLocaleString([Js.Date.make()])
665709
// returns "2020-3-19 10:52:11" for locale de_DE.utf8
666710
```
667711
*/
712+
@deprecated({
713+
reason: "Use `Array.toLocaleString` instead.",
714+
migrate: Array.toLocaleString(),
715+
})
668716
@send
669717
external toLocaleString: t<'a> => string = "toLocaleString"
670718

@@ -1063,6 +1111,10 @@ Js.Array.unsafe_get(arr, 3) == 103
10631111
Js.Array.unsafe_get(arr, 4) // returns undefined
10641112
```
10651113
*/
1114+
@deprecated({
1115+
reason: "Use `Array.getUnsafe` instead.",
1116+
migrate: Array.getUnsafe(),
1117+
})
10661118
external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get"
10671119

10681120
/**
@@ -1087,4 +1139,8 @@ Js.Array.unsafe_set(arr, -1, 66)
10871139
// you don't want to know.
10881140
```
10891141
*/
1142+
@deprecated({
1143+
reason: "Use `Array.setUnsafe` instead.",
1144+
migrate: Array.setUnsafe(),
1145+
})
10901146
external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set"

packages/@rescript/runtime/Js_string.res

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ Js.String2.make(3.5) == "3.5"
4242
Js.String2.make([1, 2, 3]) == "1,2,3"
4343
```
4444
*/
45+
@deprecated({
46+
reason: "Use `String.make` instead.",
47+
migrate: String.make(),
48+
})
4549
@val
4650
external make: 'a => t = "String"
4751

@@ -58,6 +62,10 @@ Js.String2.fromCharCode(0xd55c) == `한`
5862
Js.String2.fromCharCode(-64568) == `ψ`
5963
```
6064
*/
65+
@deprecated({
66+
reason: "Use `String.fromCharCode` instead.",
67+
migrate: String.fromCharCode(),
68+
})
6169
@val
6270
external fromCharCode: int => t = "String.fromCharCode"
6371

@@ -67,7 +75,12 @@ corresponding to the given numbers, using the same rules as `fromCharCode`. See
6775
[`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
6876
on MDN.
6977
*/
70-
@val @variadic
78+
@deprecated({
79+
reason: "Use `String.fromCharCodeMany` instead.",
80+
migrate: String.fromCharCodeMany(),
81+
})
82+
@val
83+
@variadic
7184
external fromCharCodeMany: array<int> => t = "String.fromCharCode"
7285

7386
/**
@@ -89,6 +102,10 @@ Js.String2.fromCodePoint(0xd55c) == `한`
89102
Js.String2.fromCodePoint(0x1f63a) == `😺`
90103
```
91104
*/
105+
@deprecated({
106+
reason: "Use `String.fromCodePoint` instead.",
107+
migrate: String.fromCodePoint(),
108+
})
92109
@val
93110
external fromCodePoint: int => t = "String.fromCodePoint"
94111

@@ -106,7 +123,12 @@ on MDN.
106123
Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺`
107124
```
108125
*/
109-
@val @variadic
126+
@deprecated({
127+
reason: "Use `String.fromCodePointMany` instead.",
128+
migrate: String.fromCodePointMany(),
129+
})
130+
@val
131+
@variadic
110132
external fromCodePointMany: array<int> => t = "String.fromCodePoint"
111133

112134
/* String.raw: ES2015, meant to be used with template strings, not directly */
@@ -122,6 +144,10 @@ on MDN.
122144
Js.String2.length("abcd") == 4
123145
```
124146
*/
147+
@deprecated({
148+
reason: "Use `String.length` instead.",
149+
migrate: String.length(),
150+
})
125151
@get
126152
external length: t => int = "length"
127153

@@ -138,6 +164,10 @@ Js.String2.get("Reason", 4) == "o"
138164
Js.String2.get(`Rẽasöń`, 5) == `ń`
139165
```
140166
*/
167+
@deprecated({
168+
reason: "Use `String.get` instead.",
169+
migrate: String.get(),
170+
})
141171
@get_index
142172
external get: (t, int) => t = ""
143173

@@ -465,6 +495,10 @@ on MDN.
465495
See also [Unicode technical report #15](https://unicode.org/reports/tr15/) for
466496
details.
467497
*/
498+
@deprecated({
499+
reason: "Use `String.normalize` instead.",
500+
migrate: String.normalize(),
501+
})
468502
@send
469503
external normalize: t => t = "normalize"
470504

@@ -933,6 +967,10 @@ Js.String.toLowerCase(`ΣΠ`) == `σπ`
933967
Js.String.toLowerCase(`ΠΣ`) == `πς`
934968
```
935969
*/
970+
@deprecated({
971+
reason: "Use `String.toLowerCase` instead.",
972+
migrate: String.toLowerCase(),
973+
})
936974
@send
937975
external toLowerCase: t => t = "toLowerCase"
938976

@@ -942,6 +980,10 @@ external toLowerCase: t => t = "toLowerCase"
942980
See [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
943981
on MDN.
944982
*/
983+
@deprecated({
984+
reason: "Use `String.toLocaleLowerCase` instead.",
985+
migrate: String.toLocaleLowerCase(),
986+
})
945987
@send
946988
external toLocaleLowerCase: t => t = "toLocaleLowerCase"
947989

@@ -962,6 +1004,10 @@ Js.String.toUpperCase(`Straße`) == `STRASSE`
9621004
Js.String.toUpperCase(`πς`) == `ΠΣ`
9631005
```
9641006
*/
1007+
@deprecated({
1008+
reason: "Use `String.toUpperCase` instead.",
1009+
migrate: String.toUpperCase(),
1010+
})
9651011
@send
9661012
external toUpperCase: t => t = "toUpperCase"
9671013

@@ -971,6 +1017,10 @@ external toUpperCase: t => t = "toUpperCase"
9711017
See [`String.to:LocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
9721018
on MDN.
9731019
*/
1020+
@deprecated({
1021+
reason: "Use `String.toLocaleUpperCase` instead.",
1022+
migrate: String.toLocaleUpperCase(),
1023+
})
9741024
@send
9751025
external toLocaleUpperCase: t => t = "toLocaleUpperCase"
9761026

@@ -988,6 +1038,10 @@ Js.String.trim(" abc def ") == "abc def"
9881038
Js.String.trim("\n\r\t abc def \n\n\t\r ") == "abc def"
9891039
```
9901040
*/
1041+
@deprecated({
1042+
reason: "Use `String.trim` instead.",
1043+
migrate: String.trim(),
1044+
})
9911045
@send
9921046
external trim: t => t = "trim"
9931047

@@ -1041,4 +1095,7 @@ let arr = Js.Array2.fromMap(Js.String.castToArrayLike(s), x => x)
10411095
arr == ["a", "b", "c", "d", "e"]
10421096
```
10431097
*/
1098+
@deprecated(
1099+
"This has been deprecated and will be removed in v13. Use functions from the `String` module instead."
1100+
)
10441101
external castToArrayLike: t => Js_array2.array_like<t> = "%identity"

packages/@rescript/runtime/Js_typed_array.res

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ JavaScript Typed Array API
3030

3131
@@warning("-103")
3232

33+
@deprecated({
34+
reason: "Use `ArrayBuffer.t` instead.",
35+
migrate: %replace.type(: ArrayBuffer.t),
36+
})
3337
type array_buffer = Js_typed_array2.array_buffer
38+
39+
@deprecated(
40+
"This has been deprecated and will be removed in v13. Use functions and types from the `TypedArray` module instead."
41+
)
3442
type array_like<'a> = Js_typed_array2.array_like<'a>
3543

3644
module type Type = {
@@ -1489,12 +1497,20 @@ module Float32Array = {
14891497
// @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf"
14901498

14911499
// @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */
1500+
@deprecated({
1501+
reason: "Use `TypedArray.slice` instead.",
1502+
migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")),
1503+
})
14921504
external slice: (~start: int, ~end_: int) => t = "slice"
14931505

14941506
// @bs.send.pipe(: t) external copy: t = "slice"
14951507
// @bs.send.pipe(: t) external sliceFrom: int => t = "slice"
14961508

14971509
// @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */
1510+
@deprecated({
1511+
reason: "Use `TypedArray.subarray` instead.",
1512+
migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")),
1513+
})
14981514
external subarray: (~start: int, ~end_: int) => t = "subarray"
14991515

15001516
// @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray"

0 commit comments

Comments
 (0)