Skip to content

Commit 002fa11

Browse files
committed
add type safety, fix revealed typos
1 parent d52c2ca commit 002fa11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/svelte/src/reactivity/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { source } from '../internal/client/reactivity/sources';
22
import { get, set } from '../internal/client/runtime';
33

4+
/** @type {Array<keyof Date>} */
45
const read = [
56
'getDate',
67
'getDay',
@@ -20,18 +21,20 @@ const read = [
2021
'getUTCMinutes',
2122
'getUTCMonth',
2223
'getUTCSeconds',
24+
// @ts-expect-error this is deprecated
2325
'getYear',
2426
'toDateString',
2527
'toISOString',
2628
'toJSON',
2729
'toLocaleDateString',
28-
'toLocalString',
29-
'toLocalTimeString',
30+
'toLocaleString',
31+
'toLocaleTimeString',
3032
'toString',
3133
'toTimeString',
3234
'toUTCString'
3335
];
3436

37+
/** @type {Array<keyof Date>} */
3538
const write = [
3639
'setDate',
3740
'setFullYear',
@@ -48,6 +51,7 @@ const write = [
4851
'setUTCMinutes',
4952
'setUTCMonth',
5053
'setUTCSeconds',
54+
// @ts-expect-error this is deprecated
5155
'setYear'
5256
];
5357

@@ -61,6 +65,7 @@ class ReactiveDate extends Date {
6165
ReactiveDate.#inited = true;
6266
const proto = ReactiveDate.prototype;
6367
const date_proto = Date.prototype;
68+
6469
for (const method of read) {
6570
// @ts-ignore
6671
proto[method] = function () {
@@ -69,6 +74,7 @@ class ReactiveDate extends Date {
6974
return date_proto[method].call(this);
7075
};
7176
}
77+
7278
for (const method of write) {
7379
// @ts-ignore
7480
proto[method] = function (/** @type {any} */ ...args) {

0 commit comments

Comments
 (0)