Skip to content

Commit

Permalink
fix(dts): add separate file to add missing arrayBuffer and sharedArra…
Browse files Browse the repository at this point in the history
…yBuffer types
  • Loading branch information
indrajitbnikam committed Jun 14, 2023
1 parent 541081d commit 5925906
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const libEntries: [string, string][] = [
["esnext.array", "lib.es2023.array.d.ts"],
["esnext.collection", "lib.es2023.collection.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["esnext.arraybuffer", "lib.esnext.arraybuffer.d.ts"],
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
["esnext.intl", "lib.esnext.intl.d.ts"],
["esnext.bigint", "lib.es2020.bigint.d.ts"],
Expand Down Expand Up @@ -3964,4 +3965,4 @@ function getDefaultValueForOption(option: CommandLineOption): {} {
if (value !== undefined) return value;
return Debug.fail("Expected 'option.type' to have entries.");
}
}
}
24 changes: 1 addition & 23 deletions src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,21 +1668,6 @@ interface ArrayBuffer {
*/
readonly byteLength: number;

/**
* Read-only. The maximum length that this ArrayBuffer can be resized to (in bytes).
*/
readonly maxByteLength: number;

/**
* Read-only. Whether this ArrayBuffer can be resized or not.
*/
readonly resizable: boolean;

/**
* Resizes the ArrayBuffer to the specified size (in bytes).
*/
resize(newLength: number): undefined;

/**
* Returns a section of an ArrayBuffer.
*/
Expand All @@ -1697,16 +1682,9 @@ interface ArrayBufferTypes {
}
type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];

/**
* ArrayBuffer constructor options
*/
interface ArrayBufferOptions {
maxByteLength?: number;
}

interface ArrayBufferConstructor {
readonly prototype: ArrayBuffer;
new(byteLength: number, options?: ArrayBufferOptions): ArrayBuffer;
new(byteLength: number): ArrayBuffer;
isView(arg: any): arg is ArrayBufferView;
}
declare var ArrayBuffer: ArrayBufferConstructor;
Expand Down
58 changes: 58 additions & 0 deletions src/lib/esnext.arraybuffer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
interface ArrayBuffer {
/**
* Read-only. The maximum length that this ArrayBuffer can be resized to (in bytes).
*/
readonly maxByteLength: number;

/**
* Read-only. Whether this ArrayBuffer can be resized or not.
*/
readonly resizable: boolean;

/**
* Resizes the ArrayBuffer to the specified size (in bytes).
* @param newLength The new length, in bytes, to resize the ArrayBuffer to.
*/
resize(newLength: number): undefined;
}

/**
* ArrayBuffer constructor options
*/
interface ArrayBufferOptions {
maxByteLength?: number;
}

interface ArrayBufferConstructor {
new(byteLength: number, options?: ArrayBufferOptions): ArrayBuffer;
}

interface SharedArrayBuffer {
/**
* Read-only. Whether this SharedArrayBuffer can be grow or not.
*/
readonly growable: number;

/**
* Read-only. The maximum length that this SharedArrayBuffer can be grown to (in bytes).
*/
readonly maxByteLength: number;

/**
* Grows the SharedArrayBuffer to the specified size (in bytes).
* @param newLength The new length, in bytes, to resize the SharedArrayBuffer to.
*/
grow(newLength: number): undefined;
}

/**
* ArrayBuffer constructor options
*/
interface SharedArrayBufferOptions {
maxByteLength?: number;
}

interface SharedArrayBufferConstructor {
new();
new(byteLength: number, options?: SharedArrayBufferOptions): SharedArrayBuffer;
}
1 change: 1 addition & 0 deletions src/lib/esnext.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/// <reference lib="es2023" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.arraybuffer" />
1 change: 1 addition & 0 deletions src/lib/libs.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"es2022.regexp",
"es2023.array",
"es2023.collection",
"esnext.arraybuffer",
"esnext.intl",
"decorators",
"decorators.legacy",
Expand Down

0 comments on commit 5925906

Please sign in to comment.