Skip to content

Commit 80cbefe

Browse files
committed
migrations for Js_global
1 parent b0bfe1f commit 80cbefe

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

packages/@rescript/runtime/Js_global.res

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ let cancel = () =>
5555
Js.Nullable.iter(interval.contents, intervalId => Js.Global.clearInterval(intervalId))
5656
```
5757
*/
58+
@deprecated({
59+
reason: "Use `clearInterval` instead.",
60+
migrate: clearInterval(),
61+
})
5862
@val
5963
external clearInterval: intervalId => unit = "clearInterval"
6064

@@ -78,6 +82,10 @@ let procrastinate = mins => {
7882
}
7983
```
8084
*/
85+
@deprecated({
86+
reason: "Use `clearTimeout` instead.",
87+
migrate: clearTimeout(),
88+
})
8189
@val
8290
external clearTimeout: timeoutId => unit = "clearTimeout"
8391

@@ -101,6 +109,10 @@ let tick = () => {
101109
Js.Global.setInterval(tick, 1000)
102110
```
103111
*/
112+
@deprecated({
113+
reason: "Use `setInterval` instead.",
114+
migrate: setInterval(),
115+
})
104116
@val
105117
external setInterval: (unit => unit, int) => intervalId = "setInterval"
106118

@@ -124,6 +136,10 @@ let tick = () => {
124136
Js.Global.setIntervalFloat(tick, 1000.0)
125137
```
126138
*/
139+
@deprecated({
140+
reason: "Use `setIntervalFloat` instead.",
141+
migrate: setIntervalFloat(),
142+
})
127143
@val
128144
external setIntervalFloat: (unit => unit, float) => intervalId = "setInterval"
129145

@@ -142,6 +158,10 @@ let message = "Timed out!"
142158
Js.Global.setTimeout(() => Js.log(message), 1000)
143159
```
144160
*/
161+
@deprecated({
162+
reason: "Use `setTimeout` instead.",
163+
migrate: setTimeout(),
164+
})
145165
@val
146166
external setTimeout: (unit => unit, int) => timeoutId = "setTimeout"
147167

@@ -160,6 +180,10 @@ let message = "Timed out!"
160180
Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0)
161181
```
162182
*/
183+
@deprecated({
184+
reason: "Use `setTimeoutFloat` instead.",
185+
migrate: setTimeoutFloat(),
186+
})
163187
@val
164188
external setTimeoutFloat: (unit => unit, float) => timeoutId = "setTimeout"
165189

@@ -168,6 +192,10 @@ URL-encodes a string.
168192
169193
See [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) on MDN.
170194
*/
195+
@deprecated({
196+
reason: "Use `encodeURI` instead.",
197+
migrate: encodeURI(),
198+
})
171199
@val
172200
external encodeURI: string => string = "encodeURI"
173201

@@ -176,6 +204,10 @@ Decodes a URL-enmcoded string produced by `encodeURI`
176204
177205
See [`decodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI) on MDN.
178206
*/
207+
@deprecated({
208+
reason: "Use `decodeURI` instead.",
209+
migrate: decodeURI(),
210+
})
179211
@val
180212
external decodeURI: string => string = "decodeURI"
181213

@@ -184,6 +216,10 @@ URL-encodes a string, including characters with special meaning in a URI.
184216
185217
See [`encodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) on MDN.
186218
*/
219+
@deprecated({
220+
reason: "Use `encodeURIComponent` instead.",
221+
migrate: encodeURIComponent(),
222+
})
187223
@val
188224
external encodeURIComponent: string => string = "encodeURIComponent"
189225

@@ -192,5 +228,9 @@ Decodes a URL-enmcoded string produced by `encodeURIComponent`
192228
193229
See [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) on MDN.
194230
*/
231+
@deprecated({
232+
reason: "Use `decodeURIComponent` instead.",
233+
migrate: decodeURIComponent(),
234+
})
195235
@val
196236
external decodeURIComponent: string => string = "decodeURIComponent"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
let t1: Js.Global.timeoutId = setTimeout(() => (), 1000)
2+
let t2: Js.Global.timeoutId = setTimeoutFloat(() => (), 1000.0)
3+
4+
clearTimeout(t1)
5+
6+
let i1: Js.Global.intervalId = setInterval(() => (), 2000)
7+
let i2: Js.Global.intervalId = setIntervalFloat(() => (), 2000.0)
8+
9+
clearInterval(i1)
10+
11+
let e1 = encodeURI("https://rescript-lang.org?array=[someValue]")
12+
let d1 = decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D")
13+
14+
let e2 = encodeURIComponent("array=[someValue]")
15+
let d2 = decodeURIComponent("array%3D%5BsomeValue%5D")
16+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let t1: Js.Global.timeoutId = Js.Global.setTimeout(() => (), 1000)
2+
let t2: Js.Global.timeoutId = Js.Global.setTimeoutFloat(() => (), 1000.0)
3+
4+
Js.Global.clearTimeout(t1)
5+
6+
let i1: Js.Global.intervalId = Js.Global.setInterval(() => (), 2000)
7+
let i2: Js.Global.intervalId = Js.Global.setIntervalFloat(() => (), 2000.0)
8+
9+
Js.Global.clearInterval(i1)
10+
11+
let e1 = Js.Global.encodeURI("https://rescript-lang.org?array=[someValue]")
12+
let d1 = Js.Global.decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D")
13+
14+
let e2 = Js.Global.encodeURIComponent("array=[someValue]")
15+
let d2 = Js.Global.decodeURIComponent("array%3D%5BsomeValue%5D")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is autogenerated so it can be type checked.
2+
// It's the migrated version of src/migrate/StdlibMigration_Global.res.
3+
let t1: Js.Global.timeoutId = setTimeout(() => (), 1000)
4+
let t2: Js.Global.timeoutId = setTimeoutFloat(() => (), 1000.0)
5+
6+
clearTimeout(t1)
7+
8+
let i1: Js.Global.intervalId = setInterval(() => (), 2000)
9+
let i2: Js.Global.intervalId = setIntervalFloat(() => (), 2000.0)
10+
11+
clearInterval(i1)
12+
13+
let e1 = encodeURI("https://rescript-lang.org?array=[someValue]")
14+
let d1 = decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D")
15+
16+
let e2 = encodeURIComponent("array=[someValue]")
17+
let d2 = decodeURIComponent("array%3D%5BsomeValue%5D")

0 commit comments

Comments
 (0)