mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Add missing parameters from Array.toLocaleString on ES2015 libs (#57679)
This commit is contained in:
63
tests/cases/compiler/arrayToLocaleStringES2015.ts
Normal file
63
tests/cases/compiler/arrayToLocaleStringES2015.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
// @target: es2015
|
||||
|
||||
let str: string;
|
||||
const arr = [1, 2, 3];
|
||||
str = arr.toLocaleString(); // OK
|
||||
str = arr.toLocaleString('en-US'); // OK
|
||||
str = arr.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const dates: readonly Date[] = [new Date(), new Date()];
|
||||
str = dates.toLocaleString(); // OK
|
||||
str = dates.toLocaleString('fr'); // OK
|
||||
str = dates.toLocaleString('fr', { timeZone: 'UTC' }); // OK
|
||||
|
||||
const mixed = [1, new Date(), 59782, new Date()];
|
||||
str = mixed.toLocaleString(); // OK
|
||||
str = mixed.toLocaleString('fr'); // OK
|
||||
str = mixed.toLocaleString('de', { style: 'currency', currency: 'EUR' }); // OK
|
||||
str = (mixed as ReadonlyArray<number | Date>).toLocaleString('de', { currency: 'EUR', style: 'currency', timeZone: 'UTC' }); // OK
|
||||
|
||||
const int8Array = new Int8Array(3);
|
||||
str = int8Array.toLocaleString(); // OK
|
||||
str = int8Array.toLocaleString('en-US'); // OK
|
||||
str = int8Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint8Array = new Uint8Array(3);
|
||||
str = uint8Array.toLocaleString(); // OK
|
||||
str = uint8Array.toLocaleString('en-US'); // OK
|
||||
str = uint8Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(3);
|
||||
str = uint8ClampedArray.toLocaleString(); // OK
|
||||
str = uint8ClampedArray.toLocaleString('en-US'); // OK
|
||||
str = uint8ClampedArray.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const int16Array = new Int16Array(3);
|
||||
str = int16Array.toLocaleString(); // OK
|
||||
str = int16Array.toLocaleString('en-US'); // OK
|
||||
str = int16Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint16Array = new Uint16Array(3);
|
||||
str = uint16Array.toLocaleString(); // OK
|
||||
str = uint16Array.toLocaleString('en-US'); // OK
|
||||
str = uint16Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const int32Array = new Int32Array(3);
|
||||
str = int32Array.toLocaleString(); // OK
|
||||
str = int32Array.toLocaleString('en-US'); // OK
|
||||
str = int32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint32Array = new Uint32Array(3);
|
||||
str = uint32Array.toLocaleString(); // OK
|
||||
str = uint32Array.toLocaleString('en-US'); // OK
|
||||
str = uint32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const float32Array = new Float32Array(3);
|
||||
str = float32Array.toLocaleString(); // OK
|
||||
str = float32Array.toLocaleString('en-US'); // OK
|
||||
str = float32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const float64Array = new Float64Array(3);
|
||||
str = float64Array.toLocaleString(); // OK
|
||||
str = float64Array.toLocaleString('en-US'); // OK
|
||||
str = float64Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
77
tests/cases/compiler/arrayToLocaleStringES2020.ts
Normal file
77
tests/cases/compiler/arrayToLocaleStringES2020.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
// @target: es2020
|
||||
|
||||
let str: string;
|
||||
const arr = [1, 2, 3];
|
||||
str = arr.toLocaleString(); // OK
|
||||
str = arr.toLocaleString('en-US'); // OK
|
||||
str = arr.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const dates: readonly Date[] = [new Date(), new Date()];
|
||||
str = dates.toLocaleString(); // OK
|
||||
str = dates.toLocaleString('fr'); // OK
|
||||
str = dates.toLocaleString('fr', { timeZone: 'UTC' }); // OK
|
||||
|
||||
const mixed = [1, new Date(), 59782, new Date()];
|
||||
str = mixed.toLocaleString(); // OK
|
||||
str = mixed.toLocaleString('de', { style: 'currency', currency: 'EUR' }); // OK
|
||||
str = (mixed as ReadonlyArray<number | Date>).toLocaleString('de', { currency: 'EUR', style: 'currency', timeZone: 'UTC' }); // OK
|
||||
|
||||
const bigInts = [BigInt(1), BigInt(2), BigInt(3)];
|
||||
str = bigInts.toLocaleString(); // OK
|
||||
str = bigInts.toLocaleString('en-US'); // OK
|
||||
str = bigInts.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const int8Array = new Int8Array(3);
|
||||
str = int8Array.toLocaleString(); // OK
|
||||
str = int8Array.toLocaleString('en-US'); // OK
|
||||
str = int8Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint8Array = new Uint8Array(3);
|
||||
str = uint8Array.toLocaleString(); // OK
|
||||
str = uint8Array.toLocaleString('en-US'); // OK
|
||||
str = uint8Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(3);
|
||||
str = uint8ClampedArray.toLocaleString(); // OK
|
||||
str = uint8ClampedArray.toLocaleString('en-US'); // OK
|
||||
str = uint8ClampedArray.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const int16Array = new Int16Array(3);
|
||||
str = int16Array.toLocaleString(); // OK
|
||||
str = int16Array.toLocaleString('en-US'); // OK
|
||||
str = int16Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint16Array = new Uint16Array(3);
|
||||
str = uint16Array.toLocaleString(); // OK
|
||||
str = uint16Array.toLocaleString('en-US'); // OK
|
||||
str = uint16Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const int32Array = new Int32Array(3);
|
||||
str = int32Array.toLocaleString(); // OK
|
||||
str = int32Array.toLocaleString('en-US'); // OK
|
||||
str = int32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const uint32Array = new Uint32Array(3);
|
||||
str = uint32Array.toLocaleString(); // OK
|
||||
str = uint32Array.toLocaleString('en-US'); // OK
|
||||
str = uint32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const float32Array = new Float32Array(3);
|
||||
str = float32Array.toLocaleString(); // OK
|
||||
str = float32Array.toLocaleString('en-US'); // OK
|
||||
str = float32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const float64Array = new Float64Array(3);
|
||||
str = float64Array.toLocaleString(); // OK
|
||||
str = float64Array.toLocaleString('en-US'); // OK
|
||||
str = float64Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const bigInt64Array = new BigInt64Array(3);
|
||||
str = bigInt64Array.toLocaleString(); // OK
|
||||
str = bigInt64Array.toLocaleString('en-US'); // OK
|
||||
str = bigInt64Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
|
||||
const bigIntUint64Array = new BigUint64Array(3);
|
||||
str = bigIntUint64Array.toLocaleString(); // OK
|
||||
str = bigIntUint64Array.toLocaleString('en-US'); // OK
|
||||
str = bigIntUint64Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK
|
||||
57
tests/cases/compiler/arrayToLocaleStringES5.ts
Normal file
57
tests/cases/compiler/arrayToLocaleStringES5.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// @target: es5
|
||||
|
||||
let str: string;
|
||||
const arr = [1, 2, 3];
|
||||
str = arr.toLocaleString(); // OK
|
||||
str = arr.toLocaleString('en-US'); // should be error
|
||||
str = arr.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const dates: readonly Date[] = [new Date(), new Date()];
|
||||
str = dates.toLocaleString(); // OK
|
||||
str = dates.toLocaleString('fr'); // should be error
|
||||
str = dates.toLocaleString('fr', { timeZone: 'UTC' }); // should be error
|
||||
|
||||
const int8Array = new Int8Array(3);
|
||||
str = int8Array.toLocaleString(); // OK
|
||||
str = int8Array.toLocaleString('en-US'); // should be error
|
||||
str = int8Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const uint8Array = new Uint8Array(3);
|
||||
str = uint8Array.toLocaleString(); // OK
|
||||
str = uint8Array.toLocaleString('en-US'); // should be error
|
||||
str = uint8Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(3);
|
||||
str = uint8ClampedArray.toLocaleString(); // OK
|
||||
str = uint8ClampedArray.toLocaleString('en-US'); // should be error
|
||||
str = uint8ClampedArray.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const int16Array = new Int16Array(3);
|
||||
str = int16Array.toLocaleString(); // OK
|
||||
str = int16Array.toLocaleString('en-US'); // should be error
|
||||
str = int16Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const uint16Array = new Uint16Array(3);
|
||||
str = uint16Array.toLocaleString(); // OK
|
||||
str = uint16Array.toLocaleString('en-US'); // should be error
|
||||
str = uint16Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const int32Array = new Int32Array(3);
|
||||
str = int32Array.toLocaleString(); // OK
|
||||
str = int32Array.toLocaleString('en-US'); // should be error
|
||||
str = int32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const uint32Array = new Uint32Array(3);
|
||||
str = uint32Array.toLocaleString(); // OK
|
||||
str = uint32Array.toLocaleString('en-US'); // should be error
|
||||
str = uint32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const float32Array = new Float32Array(3);
|
||||
str = float32Array.toLocaleString(); // OK
|
||||
str = float32Array.toLocaleString('en-US'); // should be error
|
||||
str = float32Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
|
||||
const float64Array = new Float64Array(3);
|
||||
str = float64Array.toLocaleString(); // OK
|
||||
str = float64Array.toLocaleString('en-US'); // should be error
|
||||
str = float64Array.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error
|
||||
Reference in New Issue
Block a user