Skip to content

Commit 63f5689

Browse files
gkzmeta-codesync[bot]
authored andcommitted
[flow] Add bigint functions to DataView
Summary: Changelog: [lib] Add bigint functions to DataView Reviewed By: marcoww6 Differential Revision: D85780346 fbshipit-source-id: 716caa893748c6318152020632f4ae6b8a79e2af
1 parent 90b2b7d commit 63f5689

8 files changed

Lines changed: 132 additions & 104 deletions

File tree

lib/core.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,6 +2758,34 @@ declare class DataView {
27582758
* otherwise a little-endian value should be written.
27592759
*/
27602760
setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void;
2761+
/**
2762+
* Gets the BigInt64 value at the specified byte offset from the start of the view. There is
2763+
* no alignment constraint; multi-byte values may be fetched from any offset.
2764+
* @param byteOffset The place in the buffer at which the value should be retrieved.
2765+
* @param littleEndian If false or undefined, a big-endian value should be read.
2766+
*/
2767+
getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
2768+
/**
2769+
* Gets the BigUint64 value at the specified byte offset from the start of the view. There is
2770+
* no alignment constraint; multi-byte values may be fetched from any offset.
2771+
* @param byteOffset The place in the buffer at which the value should be retrieved.
2772+
* @param littleEndian If false or undefined, a big-endian value should be read.
2773+
*/
2774+
getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
2775+
/**
2776+
* Stores a BigInt64 value at the specified byte offset from the start of the view.
2777+
* @param byteOffset The place in the buffer at which the value should be set.
2778+
* @param value The value to set.
2779+
* @param littleEndian If false or undefined, a big-endian value should be written.
2780+
*/
2781+
setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
2782+
/**
2783+
* Stores a BigUint64 value at the specified byte offset from the start of the view.
2784+
* @param byteOffset The place in the buffer at which the value should be set.
2785+
* @param value The value to set.
2786+
* @param littleEndian If false or undefined, a big-endian value should be written.
2787+
*/
2788+
setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
27612789
}
27622790

27632791
declare function btoa(rawString: string): string;

tests/bigint/bigint.exp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ Cannot call `BigInt` with `null` bound to `value` because: [incompatible-type]
3030
^^^^ [1]
3131

3232
References:
33-
<BUILTINS>/core.js:3008:18
34-
3008| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
33+
<BUILTINS>/core.js:3036:18
34+
3036| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
3535
^^^^^^^ [2]
36-
<BUILTINS>/core.js:3008:28
37-
3008| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
36+
<BUILTINS>/core.js:3036:28
37+
3036| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
3838
^^^^^^ [3]
39-
<BUILTINS>/core.js:3008:37
40-
3008| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
39+
<BUILTINS>/core.js:3036:37
40+
3036| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
4141
^^^^^^ [4]
42-
<BUILTINS>/core.js:3008:46
43-
3008| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
42+
<BUILTINS>/core.js:3036:46
43+
3036| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
4444
^^^^^^ [5]
45-
<BUILTINS>/core.js:3008:55
46-
3008| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
45+
<BUILTINS>/core.js:3036:55
46+
3036| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
4747
^^^^^^^^^^^^ [6]
48-
<BUILTINS>/core.js:3008:70
49-
3008| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
48+
<BUILTINS>/core.js:3036:70
49+
3036| static (value: boolean | string | number | bigint | interface {} | $ReadOnlyArray<mixed>): bigint;
5050
^^^^^^^^^^^^^^^^^^^^^ [7]
5151

5252

tests/enums/enums.exp

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ Cannot instantiate `EnumValue` because in type argument `TRepresentationType`: [
4848
^^^^^^^^ [1]
4949

5050
References:
51-
<BUILTINS>/core.js:3092:32
52-
3092| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
51+
<BUILTINS>/core.js:3120:32
52+
3120| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
5353
^^^^^^ [2]
54-
<BUILTINS>/core.js:3092:41
55-
3092| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
54+
<BUILTINS>/core.js:3120:41
55+
3120| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
5656
^^^^^^ [3]
57-
<BUILTINS>/core.js:3092:50
58-
3092| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
57+
<BUILTINS>/core.js:3120:50
58+
3120| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
5959
^^^^^^ [4]
60-
<BUILTINS>/core.js:3092:59
61-
3092| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
60+
<BUILTINS>/core.js:3120:59
61+
3120| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
6262
^^^^^^^ [5]
63-
<BUILTINS>/core.js:3092:69
64-
3092| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
63+
<BUILTINS>/core.js:3120:69
64+
3120| type EnumRepresentationTypes = string | number | symbol | boolean | bigint;
6565
^^^^^^ [6]
6666

6767

@@ -143,8 +143,8 @@ Cannot cast `x` to `EnumValue` because in the enum's representation type: number
143143
^
144144

145145
References:
146-
<BUILTINS>/core.js:3106:16
147-
3106| > = $EnumValue<TRepresentationType>;
146+
<BUILTINS>/core.js:3134:16
147+
3134| > = $EnumValue<TRepresentationType>;
148148
^^^^^^^^^^^^^^^^^^^ [1]
149149
abstract-enum-value.js:35:18
150150
35| x as EnumValue<boolean>; // ERROR
@@ -161,8 +161,8 @@ Cannot cast `x` to `EnumValue` because in the enum's representation type: string
161161
^
162162

163163
References:
164-
<BUILTINS>/core.js:3106:16
165-
3106| > = $EnumValue<TRepresentationType>;
164+
<BUILTINS>/core.js:3134:16
165+
3134| > = $EnumValue<TRepresentationType>;
166166
^^^^^^^^^^^^^^^^^^^ [1]
167167
abstract-enum-value.js:35:18
168168
35| x as EnumValue<boolean>; // ERROR
@@ -234,8 +234,8 @@ Cannot instantiate `Enum` because in type argument `TEnumValue`: boolean [1] is
234234
^^^^^^^ [1]
235235

236236
References:
237-
<BUILTINS>/core.js:3123:24
238-
3123| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
237+
<BUILTINS>/core.js:3151:24
238+
3151| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
239239
^^^^^^^^^^^ [2]
240240

241241

@@ -266,11 +266,11 @@ string [3] is incompatible with boolean [4]. [incompatible-type]
266266
^
267267

268268
References:
269-
<BUILTINS>/core.js:3123:12
270-
3123| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
269+
<BUILTINS>/core.js:3151:12
270+
3151| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
271271
^^^^^^^^^^ [1]
272-
<BUILTINS>/core.js:3105:4
273-
3105| +TRepresentationType: EnumRepresentationTypes = EnumRepresentationTypes
272+
<BUILTINS>/core.js:3133:4
273+
3133| +TRepresentationType: EnumRepresentationTypes = EnumRepresentationTypes
274274
^^^^^^^^^^^^^^^^^^^ [2]
275275
abstract-enum.js:15:35
276276
15| declare const x: Enum<EnumValue<string>>;
@@ -290,8 +290,8 @@ Cannot cast `x` to `Enum` because in type argument `TEnumValue` [1]: `EnumValue`
290290
^
291291

292292
References:
293-
<BUILTINS>/core.js:3123:12
294-
3123| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
293+
<BUILTINS>/core.js:3151:12
294+
3151| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
295295
^^^^^^^^^^ [1]
296296
abstract-enum.js:15:25
297297
15| declare const x: Enum<EnumValue<string>>;
@@ -340,8 +340,8 @@ Cannot call `f` because in type argument `TEnumValue`: boolean [1] is incompatib
340340
^^^^ [1]
341341

342342
References:
343-
<BUILTINS>/core.js:3123:24
344-
3123| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
343+
<BUILTINS>/core.js:3151:24
344+
3151| type Enum<+TEnumValue: EnumValue<> = EnumValue<>> = $Enum<TEnumValue>;
345345
^^^^^^^^^^^ [2]
346346

347347

@@ -1957,8 +1957,8 @@ References:
19571957
exhaustive-check.js:3:6
19581958
3| enum E {
19591959
^ [3]
1960-
<BUILTINS>/core.js:2893:3
1961-
2893| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
1960+
<BUILTINS>/core.js:2921:3
1961+
2921| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
19621962
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [4]
19631963

19641964

@@ -2579,15 +2579,15 @@ Cannot get `E.nonExistent` because property `nonExistent` is missing in `$EnumPr
25792579
^^^^^^^^^^^
25802580

25812581
References:
2582-
<BUILTINS>/core.js:2890:59
2582+
<BUILTINS>/core.js:2918:59
25832583
v-
2584-
2890| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2585-
2891| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2586-
2892| getName(this: TEnum, input: TEnumValue): string,
2587-
2893| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2588-
2894| members(this: TEnum): Iterator<TEnumValue>,
2589-
2895| __proto__: null,
2590-
2896| |}
2584+
2918| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2585+
2919| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2586+
2920| getName(this: TEnum, input: TEnumValue): string,
2587+
2921| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2588+
2922| members(this: TEnum): Iterator<TEnumValue>,
2589+
2923| __proto__: null,
2590+
2924| |}
25912591
-^ [1]
25922592

25932593

@@ -2600,15 +2600,15 @@ Cannot call `E.nonExistent` because property `nonExistent` is missing in `$EnumP
26002600
^^^^^^^^^^^
26012601

26022602
References:
2603-
<BUILTINS>/core.js:2890:59
2603+
<BUILTINS>/core.js:2918:59
26042604
v-
2605-
2890| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2606-
2891| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2607-
2892| getName(this: TEnum, input: TEnumValue): string,
2608-
2893| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2609-
2894| members(this: TEnum): Iterator<TEnumValue>,
2610-
2895| __proto__: null,
2611-
2896| |}
2605+
2918| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2606+
2919| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2607+
2920| getName(this: TEnum, input: TEnumValue): string,
2608+
2921| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2609+
2922| members(this: TEnum): Iterator<TEnumValue>,
2610+
2923| __proto__: null,
2611+
2924| |}
26122612
-^ [1]
26132613

26142614

@@ -2635,15 +2635,15 @@ Cannot call `E.A` because property `A` is missing in `$EnumProto` [1]. [prop-mis
26352635
^
26362636

26372637
References:
2638-
<BUILTINS>/core.js:2890:59
2638+
<BUILTINS>/core.js:2918:59
26392639
v-
2640-
2890| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2641-
2891| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2642-
2892| getName(this: TEnum, input: TEnumValue): string,
2643-
2893| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2644-
2894| members(this: TEnum): Iterator<TEnumValue>,
2645-
2895| __proto__: null,
2646-
2896| |}
2640+
2918| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2641+
2919| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2642+
2920| getName(this: TEnum, input: TEnumValue): string,
2643+
2921| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2644+
2922| members(this: TEnum): Iterator<TEnumValue>,
2645+
2923| __proto__: null,
2646+
2924| |}
26472647
-^ [1]
26482648

26492649

@@ -2656,15 +2656,15 @@ Cannot call `E.toString` because property `toString` is missing in `$EnumProto`
26562656
^^^^^^^^
26572657

26582658
References:
2659-
<BUILTINS>/core.js:2890:59
2659+
<BUILTINS>/core.js:2918:59
26602660
v-
2661-
2890| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2662-
2891| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2663-
2892| getName(this: TEnum, input: TEnumValue): string,
2664-
2893| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2665-
2894| members(this: TEnum): Iterator<TEnumValue>,
2666-
2895| __proto__: null,
2667-
2896| |}
2661+
2918| type $EnumProto<TEnum, TEnumValue, TRepresentationType> = {|
2662+
2919| cast(this: TEnum, input: ?TRepresentationType): void | TEnumValue,
2663+
2920| getName(this: TEnum, input: TEnumValue): string,
2664+
2921| isValid(this: TEnum, input: ?TRepresentationType | TEnumValue): boolean,
2665+
2922| members(this: TEnum): Iterator<TEnumValue>,
2666+
2923| __proto__: null,
2667+
2924| |}
26682668
-^ [1]
26692669

26702670

@@ -2677,8 +2677,8 @@ Cannot cast `E.getName(...)` to boolean because string [1] is incompatible with
26772677
^^^^^^^^^^^^^^
26782678

26792679
References:
2680-
<BUILTINS>/core.js:2892:44
2681-
2892| getName(this: TEnum, input: TEnumValue): string,
2680+
<BUILTINS>/core.js:2920:44
2681+
2920| getName(this: TEnum, input: TEnumValue): string,
26822682
^^^^^^ [1]
26832683
methods.js:44:19
26842684
44| E.getName(E.B) as boolean; // Error - wrong type

tests/get_def_enums/get_def_enums.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ library.js:4:3,4:5
2828

2929
main.js:27:13
3030
Flags:
31-
[LIB] core.js:2891:3,2891:6
31+
[LIB] core.js:2919:3,2919:6
3232

3333
main.js:30:13
3434
Flags:
35-
[LIB] core.js:2893:3,2893:9
35+
[LIB] core.js:2921:3,2921:9
3636

tests/mapped_type_utilities/mapped_type_utilities.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ Cannot cast `pickedO1.bar` to string because undefined [1] is incompatible with
153153
^^^^^^^^^^^^
154154

155155
References:
156-
<BUILTINS>/core.js:3068:62
157-
3068| type Pick<O: interface {}, Keys: $Keys<O>> = {[key in Keys]: O[key]};
156+
<BUILTINS>/core.js:3096:62
157+
3096| type Pick<O: interface {}, Keys: $Keys<O>> = {[key in Keys]: O[key]};
158158
^^^^^^ [1]
159159
pick.js:9:16
160160
9| (pickedO1.bar: string); // ERROR bar is optional

tests/meta_property/meta_property.exp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Cannot cast `import.meta` to number literal `1` because `Import$Meta` [1] is inc
88
^^^^^^^^^^^
99

1010
References:
11-
<BUILTINS>/core.js:3001:20
11+
<BUILTINS>/core.js:3029:20
1212
v
13-
3001| type Import$Meta = {
14-
3002| [string]: mixed,
15-
3003| url?: string,
16-
3004| ...
17-
3005| };
13+
3029| type Import$Meta = {
14+
3030| [string]: mixed,
15+
3031| url?: string,
16+
3032| ...
17+
3033| };
1818
^ [1]
1919
import_meta.js:5:15
2020
5| (import.meta: 1); // Error
@@ -31,8 +31,8 @@ Cannot cast `import.meta.XXX` to number literal `1` because mixed [1] is incompa
3131
^^^^^^^^^^^^^^^
3232

3333
References:
34-
<BUILTINS>/core.js:3002:13
35-
3002| [string]: mixed,
34+
<BUILTINS>/core.js:3030:13
35+
3030| [string]: mixed,
3636
^^^^^ [1]
3737
import_meta.js:6:19
3838
6| (import.meta.XXX: 1); // Error

tests/provider_havoc/provider_havoc.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ References:
204204
provider_edge_cases.js:5:28
205205
5| if (((x: mixed) => 42) === console.log) { // constant-condition error
206206
^^^^^^^^^^^ [2]
207-
<BUILTINS>/core.js:2877:5
208-
2877| log(...data: Array<any>): void,
207+
<BUILTINS>/core.js:2905:5
208+
2905| log(...data: Array<any>): void,
209209
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [3]
210210

211211

0 commit comments

Comments
 (0)