Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to use string literal type in ArrayBuffer's Symbol.toStringTag #60150

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 0 additions & 6 deletions src/harness/vfsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,6 @@ export class FileSystem {
return realpath;
}

/**
* Read from a file.
*
* 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
Comment on lines -635 to -640
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this type because CI failed, but it might be better to revert it.

/**
* Read from a file.
*
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