TypeScript Version:
3.4.3
Search Terms:
subarray
Code
const a = new Uint8Array(50);
const b = a.subarray();
Expected behavior:
No compiler error. As per the ES6 spec:
https://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype.subarray
TypedArray.subarray() doesn't require any arguments - both begin and end are optional according to the prototype declaration. However, reading the functional steps shows end being explicitly called out as optional, whereas begin is not. At the least, the functional steps are inconsistent with the prototype declaration, but I believe TypeScript should adhere to the prototype in such a case.
Actual behavior:
src/foo.ts:566:20 - error TS2554: Expected 1-2 arguments, but got 0.
566 const result = input.subarray();
~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.es5.d.ts:2180:14
2180 subarray(begin: number, end?: number): Uint8Array;
~~~~~~~~~~~~~
An argument for 'begin' was not provided.
TypeScript Version:
3.4.3
Search Terms:
subarray
Code
Expected behavior:
No compiler error. As per the ES6 spec:
https://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype.subarray
TypedArray.subarray()doesn't require any arguments - bothbeginandendare optional according to the prototype declaration. However, reading the functional steps showsendbeing explicitly called out as optional, whereasbeginis not. At the least, the functional steps are inconsistent with the prototype declaration, but I believe TypeScript should adhere to the prototype in such a case.Actual behavior: