What\'s the meaning of the typescript definition for ArrayBufferLike
?
interface ArrayBufferTypes {
ArrayBuffer: ArrayBuffer;
}
type ArrayBu
The reason is to allow ArrayBufferTypes
to be extended using declaration merging.
This single-member interface is defined in lib.es5.d.ts
interface ArrayBufferTypes {
ArrayBuffer: ArrayBuffer;
}
But the interface with the same name, but having another member, is defined in es2017.sharedmemory.d.ts
interface ArrayBufferTypes {
SharedArrayBuffer: SharedArrayBuffer;
}
When both type declarations are included in the program, declarations will be merged and the resulting union type
type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];
will have two members now: ArrayBuffer
and SharedArrayBuffer.