Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/harness/vfsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ export class FileSystem {
*
* NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
*/
public readFileSync(path: string, encoding?: null): Buffer; // eslint-disable-line no-restricted-syntax
public readFileSync(path: string, encoding?: null): Buffer<ArrayBuffer>; // eslint-disable-line no-restricted-syntax
/**
* Read from a file.
*
Expand All @@ -649,7 +649,7 @@ export class FileSystem {
*
* NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
*/
public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer; // eslint-disable-line no-restricted-syntax
public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer<ArrayBuffer>; // eslint-disable-line no-restricted-syntax
public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-restricted-syntax
const { node } = this._walk(this._resolve(path));
if (!node) throw createIOError("ENOENT");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/es2015.symbol.wellknown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ interface String {
}

interface ArrayBuffer {
readonly [Symbol.toStringTag]: string;
readonly [Symbol.toStringTag]: "ArrayBuffer";
}

interface DataView<TArrayBuffer extends ArrayBufferLike> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
assignSharedArrayBufferToArrayBuffer.ts(1,5): error TS2322: Type 'SharedArrayBuffer' is not assignable to type 'ArrayBuffer'.
Types of property '[Symbol.toStringTag]' are incompatible.
Type '"SharedArrayBuffer"' is not assignable to type '"ArrayBuffer"'.


==== assignSharedArrayBufferToArrayBuffer.ts (1 errors) ====
var foo: ArrayBuffer = new SharedArrayBuffer(1024); // should error
~~~
!!! error TS2322: Type 'SharedArrayBuffer' is not assignable to type 'ArrayBuffer'.
!!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible.
!!! error TS2322: Type '"SharedArrayBuffer"' is not assignable to type '"ArrayBuffer"'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//// [tests/cases/conformance/es2017/assignSharedArrayBufferToArrayBuffer.ts] ////

//// [assignSharedArrayBufferToArrayBuffer.ts]
var foo: ArrayBuffer = new SharedArrayBuffer(1024); // should error

//// [assignSharedArrayBufferToArrayBuffer.js]
var foo = new SharedArrayBuffer(1024); // should error
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//// [tests/cases/conformance/es2017/assignSharedArrayBufferToArrayBuffer.ts] ////

=== assignSharedArrayBufferToArrayBuffer.ts ===
var foo: ArrayBuffer = new SharedArrayBuffer(1024); // should error
>foo : Symbol(foo, Decl(assignSharedArrayBufferToArrayBuffer.ts, 0, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>SharedArrayBuffer : Symbol(SharedArrayBuffer, Decl(lib.es2017.sharedmemory.d.ts, --, --), Decl(lib.es2017.sharedmemory.d.ts, --, --))

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/conformance/es2017/assignSharedArrayBufferToArrayBuffer.ts] ////

=== assignSharedArrayBufferToArrayBuffer.ts ===
var foo: ArrayBuffer = new SharedArrayBuffer(1024); // should error
>foo : ArrayBuffer
> : ^^^^^^^^^^^
>new SharedArrayBuffer(1024) : SharedArrayBuffer
> : ^^^^^^^^^^^^^^^^^
>SharedArrayBuffer : SharedArrayBufferConstructor
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>1024 : 1024
> : ^^^^

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @target: es5
// @lib: es2015,es2017.sharedmemory

var foo: ArrayBuffer = new SharedArrayBuffer(1024); // should error