Skip to content

Commit 6f60d7f

Browse files
committed
Fix SharedArrayBuffer conflict in TS < 5.9 and @types/node@25
1 parent 80c2ad8 commit 6f60d7f

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

packages/core-js-types/src/base/proposals/array-buffer-transfer.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,34 @@ interface ArrayBuffer {
2525
*/
2626
transferToFixedLength(newByteLength?: number): ArrayBuffer;
2727
}
28+
29+
// Type compatibility hack for AllowSharedBufferSource in TypeScript < 5.9
30+
interface SharedArrayBuffer {
31+
readonly resizable: boolean;
32+
33+
readonly detached: boolean;
34+
35+
/**
36+
* Creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer.
37+
* @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer`
38+
* @throws RangeError If this `ArrayBuffer` is resizable and newByteLength is greater than the `maxByteLength` of this `ArrayBuffer`
39+
* @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations
40+
* @returns A new `ArrayBuffer` object
41+
*/
42+
transfer(newByteLength?: number): ArrayBuffer;
43+
44+
/**
45+
* Creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer.
46+
* @param newByteLength - If provided, specifies the `byteLength` of the new `ArrayBuffer`
47+
* @throws TypeError If this `ArrayBuffer` is already detached, or if it can only be detached by designated operations
48+
* @returns A new `ArrayBuffer` object
49+
*/
50+
transferToFixedLength(newByteLength?: number): ArrayBuffer;
51+
52+
/**
53+
* Resizes the ArrayBuffer to the specified size (in bytes).
54+
*
55+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize)
56+
*/
57+
resize(newByteLength?: number): void;
58+
}

tests/type-definitions/runner.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,25 @@ const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [
2525
// '5.2',
2626
] : [
2727
'5.9',
28+
'5.7',
2829
'5.6',
2930
];
3031

3132
const ENVIRONMENTS = ALL_TESTS ? [
3233
null,
33-
// '@types/node@25', // fails
34+
'@types/node@25',
3435
'@types/node@24',
3536
'@types/node@22',
3637
'@types/node@20',
3738
'@types/node@18',
3839
'@types/node@16',
3940
// '@types/node@15', // fails
40-
// '@types/bun@latest', // conflicts with DOM types (TextDecorator, SharedArrayBuffer...)
41+
// '@types/bun@latest', // ArrayBuffer.resize signature incorrect. Return type ArrayBuffer instead of void.
4142
// '@types/deno@latest', // fails
4243
] : [
4344
null,
4445
'@types/node@24',
46+
'@types/node@25',
4547
];
4648

4749
const CORE_JS_MODES = [

0 commit comments

Comments
 (0)