mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-10 13:40:56 -06:00
Fix to use string literal type in ArrayBuffer's Symbol.toStringTag (#60150)
This commit is contained in:
parent
244303f92f
commit
8ae98d02d8
@ -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.
|
||||
*
|
||||
@ -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");
|
||||
|
||||
2
src/lib/es2015.symbol.wellknown.d.ts
vendored
2
src/lib/es2015.symbol.wellknown.d.ts
vendored
@ -251,7 +251,7 @@ interface String {
|
||||
}
|
||||
|
||||
interface ArrayBuffer {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
readonly [Symbol.toStringTag]: "ArrayBuffer";
|
||||
}
|
||||
|
||||
interface DataView<TArrayBuffer extends ArrayBufferLike> {
|
||||
|
||||
@ -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"'.
|
||||
@ -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
|
||||
@ -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, --, --))
|
||||
|
||||
@ -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
|
||||
> : ^^^^
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
// @target: es5
|
||||
// @lib: es2015,es2017.sharedmemory
|
||||
|
||||
var foo: ArrayBuffer = new SharedArrayBuffer(1024); // should error
|
||||
Loading…
x
Reference in New Issue
Block a user