mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Specified diagnostic for iterating known array type without --downlevelIteration (#40070)
* Specified error message for iterating known array types without --downlevelIteration * Added extra target info to diagnostic * NodeList too, a classic * PR feedback: invert to allowsStrings; required param Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
parent
7fca9267e6
commit
c3d7a56e90
@ -34905,18 +34905,8 @@ namespace ts {
|
||||
// want to say that number is not an array type. But if the input was just
|
||||
// number and string input is allowed, we want to say that number is not an
|
||||
// array type or a string type.
|
||||
const yieldType = getIterationTypeOfIterable(use, IterationTypeKind.Yield, inputType, /*errorNode*/ undefined);
|
||||
const [defaultDiagnostic, maybeMissingAwait]: [DiagnosticMessage, boolean] = !(use & IterationUse.AllowsStringInputFlag) || hasStringConstituent
|
||||
? downlevelIteration
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
|
||||
: yieldType
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type, true]
|
||||
: downlevelIteration
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
|
||||
: yieldType
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true];
|
||||
const allowsStrings = !!(use & IterationUse.AllowsStringInputFlag) && !hasStringConstituent;
|
||||
const [defaultDiagnostic, maybeMissingAwait] = getIterationDiagnosticDetails(allowsStrings, downlevelIteration);
|
||||
errorAndMaybeSuggestAwait(
|
||||
errorNode,
|
||||
maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType),
|
||||
@ -34937,6 +34927,45 @@ namespace ts {
|
||||
}
|
||||
|
||||
return (use & IterationUse.PossiblyOutOfBounds) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType;
|
||||
|
||||
function getIterationDiagnosticDetails(allowsStrings: boolean, downlevelIteration: boolean | undefined): [DiagnosticMessage, boolean] {
|
||||
if (downlevelIteration) {
|
||||
return allowsStrings
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true];
|
||||
}
|
||||
|
||||
const yieldType = getIterationTypeOfIterable(use, IterationTypeKind.Yield, inputType, /*errorNode*/ undefined);
|
||||
|
||||
if (yieldType) {
|
||||
return [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false];
|
||||
}
|
||||
|
||||
if (isES2015OrLaterIterable(inputType.symbol?.escapedName)) {
|
||||
return [Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true];
|
||||
}
|
||||
|
||||
return allowsStrings
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type, true];
|
||||
}
|
||||
}
|
||||
|
||||
function isES2015OrLaterIterable(n: __String) {
|
||||
switch (n) {
|
||||
case "Float32Array":
|
||||
case "Float64Array":
|
||||
case "Int16Array":
|
||||
case "Int32Array":
|
||||
case "Int8Array":
|
||||
case "NodeList":
|
||||
case "Uint16Array":
|
||||
case "Uint32Array":
|
||||
case "Uint8Array":
|
||||
case "Uint8ClampedArray":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3260,6 +3260,10 @@
|
||||
"category": "Error",
|
||||
"code": 2801
|
||||
},
|
||||
"Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 2802
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
65
tests/baselines/reference/typedArrays-es5.errors.txt
Normal file
65
tests/baselines/reference/typedArrays-es5.errors.txt
Normal file
@ -0,0 +1,65 @@
|
||||
tests/cases/compiler/typedArrays-es5.ts(2,5): error TS2802: Type 'Float32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(5,5): error TS2802: Type 'Float64Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(8,5): error TS2802: Type 'Int16Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(11,5): error TS2802: Type 'Int32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(14,5): error TS2802: Type 'Int8Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(17,5): error TS2802: Type 'NodeList' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(20,5): error TS2802: Type 'Uint16Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(23,5): error TS2802: Type 'Uint32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(26,5): error TS2802: Type 'Uint8Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
tests/cases/compiler/typedArrays-es5.ts(29,5): error TS2802: Type 'Uint8ClampedArray' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/typedArrays-es5.ts (10 errors) ====
|
||||
const float32Array = new Float32Array(1);
|
||||
[...float32Array];
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Float32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
[...float64Array];
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Float64Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
[...int16Array];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Int16Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
[...int32Array];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Int32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
[...int8Array];
|
||||
~~~~~~~~~
|
||||
!!! error TS2802: Type 'Int8Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const nodeList = new NodeList();
|
||||
[...nodeList];
|
||||
~~~~~~~~
|
||||
!!! error TS2802: Type 'NodeList' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
[...uint16Array];
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Uint16Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
[...uint32Array];
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Uint32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
[...uint8Array];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Uint8Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
[...uint8ClampedArray];
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2802: Type 'Uint8ClampedArray' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
||||
|
||||
|
||||
|
||||
60
tests/baselines/reference/typedArrays-es5.js
Normal file
60
tests/baselines/reference/typedArrays-es5.js
Normal file
@ -0,0 +1,60 @@
|
||||
//// [typedArrays-es5.ts]
|
||||
const float32Array = new Float32Array(1);
|
||||
[...float32Array];
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
[...float64Array];
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
[...int16Array];
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
[...int32Array];
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
[...int8Array];
|
||||
|
||||
const nodeList = new NodeList();
|
||||
[...nodeList];
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
[...uint16Array];
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
[...uint32Array];
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
[...uint8Array];
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
[...uint8ClampedArray];
|
||||
|
||||
|
||||
|
||||
|
||||
//// [typedArrays-es5.js]
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
};
|
||||
var float32Array = new Float32Array(1);
|
||||
__spreadArray([], float32Array);
|
||||
var float64Array = new Float64Array(1);
|
||||
__spreadArray([], float64Array);
|
||||
var int16Array = new Int16Array(1);
|
||||
__spreadArray([], int16Array);
|
||||
var int32Array = new Int32Array(1);
|
||||
__spreadArray([], int32Array);
|
||||
var int8Array = new Int8Array(1);
|
||||
__spreadArray([], int8Array);
|
||||
var nodeList = new NodeList();
|
||||
__spreadArray([], nodeList);
|
||||
var uint16Array = new Uint16Array(1);
|
||||
__spreadArray([], uint16Array);
|
||||
var uint32Array = new Uint32Array(1);
|
||||
__spreadArray([], uint32Array);
|
||||
var uint8Array = new Uint8Array(1);
|
||||
__spreadArray([], uint8Array);
|
||||
var uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
__spreadArray([], uint8ClampedArray);
|
||||
73
tests/baselines/reference/typedArrays-es5.symbols
Normal file
73
tests/baselines/reference/typedArrays-es5.symbols
Normal file
@ -0,0 +1,73 @@
|
||||
=== tests/cases/compiler/typedArrays-es5.ts ===
|
||||
const float32Array = new Float32Array(1);
|
||||
>float32Array : Symbol(float32Array, Decl(typedArrays-es5.ts, 0, 5))
|
||||
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...float32Array];
|
||||
>float32Array : Symbol(float32Array, Decl(typedArrays-es5.ts, 0, 5))
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
>float64Array : Symbol(float64Array, Decl(typedArrays-es5.ts, 3, 5))
|
||||
>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...float64Array];
|
||||
>float64Array : Symbol(float64Array, Decl(typedArrays-es5.ts, 3, 5))
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
>int16Array : Symbol(int16Array, Decl(typedArrays-es5.ts, 6, 5))
|
||||
>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...int16Array];
|
||||
>int16Array : Symbol(int16Array, Decl(typedArrays-es5.ts, 6, 5))
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
>int32Array : Symbol(int32Array, Decl(typedArrays-es5.ts, 9, 5))
|
||||
>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...int32Array];
|
||||
>int32Array : Symbol(int32Array, Decl(typedArrays-es5.ts, 9, 5))
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
>int8Array : Symbol(int8Array, Decl(typedArrays-es5.ts, 12, 5))
|
||||
>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...int8Array];
|
||||
>int8Array : Symbol(int8Array, Decl(typedArrays-es5.ts, 12, 5))
|
||||
|
||||
const nodeList = new NodeList();
|
||||
>nodeList : Symbol(nodeList, Decl(typedArrays-es5.ts, 15, 5))
|
||||
>NodeList : Symbol(NodeList, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
[...nodeList];
|
||||
>nodeList : Symbol(nodeList, Decl(typedArrays-es5.ts, 15, 5))
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
>uint16Array : Symbol(uint16Array, Decl(typedArrays-es5.ts, 18, 5))
|
||||
>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...uint16Array];
|
||||
>uint16Array : Symbol(uint16Array, Decl(typedArrays-es5.ts, 18, 5))
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
>uint32Array : Symbol(uint32Array, Decl(typedArrays-es5.ts, 21, 5))
|
||||
>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...uint32Array];
|
||||
>uint32Array : Symbol(uint32Array, Decl(typedArrays-es5.ts, 21, 5))
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
>uint8Array : Symbol(uint8Array, Decl(typedArrays-es5.ts, 24, 5))
|
||||
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...uint8Array];
|
||||
>uint8Array : Symbol(uint8Array, Decl(typedArrays-es5.ts, 24, 5))
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
>uint8ClampedArray : Symbol(uint8ClampedArray, Decl(typedArrays-es5.ts, 27, 5))
|
||||
>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[...uint8ClampedArray];
|
||||
>uint8ClampedArray : Symbol(uint8ClampedArray, Decl(typedArrays-es5.ts, 27, 5))
|
||||
|
||||
|
||||
|
||||
112
tests/baselines/reference/typedArrays-es5.types
Normal file
112
tests/baselines/reference/typedArrays-es5.types
Normal file
@ -0,0 +1,112 @@
|
||||
=== tests/cases/compiler/typedArrays-es5.ts ===
|
||||
const float32Array = new Float32Array(1);
|
||||
>float32Array : Float32Array
|
||||
>new Float32Array(1) : Float32Array
|
||||
>Float32Array : Float32ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...float32Array];
|
||||
>[...float32Array] : any[]
|
||||
>...float32Array : any
|
||||
>float32Array : Float32Array
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
>float64Array : Float64Array
|
||||
>new Float64Array(1) : Float64Array
|
||||
>Float64Array : Float64ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...float64Array];
|
||||
>[...float64Array] : any[]
|
||||
>...float64Array : any
|
||||
>float64Array : Float64Array
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
>int16Array : Int16Array
|
||||
>new Int16Array(1) : Int16Array
|
||||
>Int16Array : Int16ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...int16Array];
|
||||
>[...int16Array] : any[]
|
||||
>...int16Array : any
|
||||
>int16Array : Int16Array
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
>int32Array : Int32Array
|
||||
>new Int32Array(1) : Int32Array
|
||||
>Int32Array : Int32ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...int32Array];
|
||||
>[...int32Array] : any[]
|
||||
>...int32Array : any
|
||||
>int32Array : Int32Array
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
>int8Array : Int8Array
|
||||
>new Int8Array(1) : Int8Array
|
||||
>Int8Array : Int8ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...int8Array];
|
||||
>[...int8Array] : any[]
|
||||
>...int8Array : any
|
||||
>int8Array : Int8Array
|
||||
|
||||
const nodeList = new NodeList();
|
||||
>nodeList : NodeList
|
||||
>new NodeList() : NodeList
|
||||
>NodeList : { new (): NodeList; prototype: NodeList; }
|
||||
|
||||
[...nodeList];
|
||||
>[...nodeList] : any[]
|
||||
>...nodeList : any
|
||||
>nodeList : NodeList
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
>uint16Array : Uint16Array
|
||||
>new Uint16Array(1) : Uint16Array
|
||||
>Uint16Array : Uint16ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint16Array];
|
||||
>[...uint16Array] : any[]
|
||||
>...uint16Array : any
|
||||
>uint16Array : Uint16Array
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
>uint32Array : Uint32Array
|
||||
>new Uint32Array(1) : Uint32Array
|
||||
>Uint32Array : Uint32ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint32Array];
|
||||
>[...uint32Array] : any[]
|
||||
>...uint32Array : any
|
||||
>uint32Array : Uint32Array
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
>uint8Array : Uint8Array
|
||||
>new Uint8Array(1) : Uint8Array
|
||||
>Uint8Array : Uint8ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint8Array];
|
||||
>[...uint8Array] : any[]
|
||||
>...uint8Array : any
|
||||
>uint8Array : Uint8Array
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
>uint8ClampedArray : Uint8ClampedArray
|
||||
>new Uint8ClampedArray(1) : Uint8ClampedArray
|
||||
>Uint8ClampedArray : Uint8ClampedArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint8ClampedArray];
|
||||
>[...uint8ClampedArray] : any[]
|
||||
>...uint8ClampedArray : any
|
||||
>uint8ClampedArray : Uint8ClampedArray
|
||||
|
||||
|
||||
|
||||
53
tests/baselines/reference/typedArrays-es6.js
Normal file
53
tests/baselines/reference/typedArrays-es6.js
Normal file
@ -0,0 +1,53 @@
|
||||
//// [typedArrays-es6.ts]
|
||||
const float32Array = new Float32Array(1);
|
||||
[...float32Array];
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
[...float64Array];
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
[...int16Array];
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
[...int32Array];
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
[...int8Array];
|
||||
|
||||
const nodeList = new NodeList();
|
||||
[...nodeList];
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
[...uint16Array];
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
[...uint32Array];
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
[...uint8Array];
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
[...uint8ClampedArray];
|
||||
|
||||
|
||||
//// [typedArrays-es6.js]
|
||||
const float32Array = new Float32Array(1);
|
||||
[...float32Array];
|
||||
const float64Array = new Float64Array(1);
|
||||
[...float64Array];
|
||||
const int16Array = new Int16Array(1);
|
||||
[...int16Array];
|
||||
const int32Array = new Int32Array(1);
|
||||
[...int32Array];
|
||||
const int8Array = new Int8Array(1);
|
||||
[...int8Array];
|
||||
const nodeList = new NodeList();
|
||||
[...nodeList];
|
||||
const uint16Array = new Uint16Array(1);
|
||||
[...uint16Array];
|
||||
const uint32Array = new Uint32Array(1);
|
||||
[...uint32Array];
|
||||
const uint8Array = new Uint8Array(1);
|
||||
[...uint8Array];
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
[...uint8ClampedArray];
|
||||
71
tests/baselines/reference/typedArrays-es6.symbols
Normal file
71
tests/baselines/reference/typedArrays-es6.symbols
Normal file
@ -0,0 +1,71 @@
|
||||
=== tests/cases/compiler/typedArrays-es6.ts ===
|
||||
const float32Array = new Float32Array(1);
|
||||
>float32Array : Symbol(float32Array, Decl(typedArrays-es6.ts, 0, 5))
|
||||
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...float32Array];
|
||||
>float32Array : Symbol(float32Array, Decl(typedArrays-es6.ts, 0, 5))
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
>float64Array : Symbol(float64Array, Decl(typedArrays-es6.ts, 3, 5))
|
||||
>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...float64Array];
|
||||
>float64Array : Symbol(float64Array, Decl(typedArrays-es6.ts, 3, 5))
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
>int16Array : Symbol(int16Array, Decl(typedArrays-es6.ts, 6, 5))
|
||||
>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...int16Array];
|
||||
>int16Array : Symbol(int16Array, Decl(typedArrays-es6.ts, 6, 5))
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
>int32Array : Symbol(int32Array, Decl(typedArrays-es6.ts, 9, 5))
|
||||
>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...int32Array];
|
||||
>int32Array : Symbol(int32Array, Decl(typedArrays-es6.ts, 9, 5))
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
>int8Array : Symbol(int8Array, Decl(typedArrays-es6.ts, 12, 5))
|
||||
>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...int8Array];
|
||||
>int8Array : Symbol(int8Array, Decl(typedArrays-es6.ts, 12, 5))
|
||||
|
||||
const nodeList = new NodeList();
|
||||
>nodeList : Symbol(nodeList, Decl(typedArrays-es6.ts, 15, 5))
|
||||
>NodeList : Symbol(NodeList, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.iterable.d.ts, --, --))
|
||||
|
||||
[...nodeList];
|
||||
>nodeList : Symbol(nodeList, Decl(typedArrays-es6.ts, 15, 5))
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
>uint16Array : Symbol(uint16Array, Decl(typedArrays-es6.ts, 18, 5))
|
||||
>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...uint16Array];
|
||||
>uint16Array : Symbol(uint16Array, Decl(typedArrays-es6.ts, 18, 5))
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
>uint32Array : Symbol(uint32Array, Decl(typedArrays-es6.ts, 21, 5))
|
||||
>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...uint32Array];
|
||||
>uint32Array : Symbol(uint32Array, Decl(typedArrays-es6.ts, 21, 5))
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
>uint8Array : Symbol(uint8Array, Decl(typedArrays-es6.ts, 24, 5))
|
||||
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...uint8Array];
|
||||
>uint8Array : Symbol(uint8Array, Decl(typedArrays-es6.ts, 24, 5))
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
>uint8ClampedArray : Symbol(uint8ClampedArray, Decl(typedArrays-es6.ts, 27, 5))
|
||||
>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[...uint8ClampedArray];
|
||||
>uint8ClampedArray : Symbol(uint8ClampedArray, Decl(typedArrays-es6.ts, 27, 5))
|
||||
|
||||
110
tests/baselines/reference/typedArrays-es6.types
Normal file
110
tests/baselines/reference/typedArrays-es6.types
Normal file
@ -0,0 +1,110 @@
|
||||
=== tests/cases/compiler/typedArrays-es6.ts ===
|
||||
const float32Array = new Float32Array(1);
|
||||
>float32Array : Float32Array
|
||||
>new Float32Array(1) : Float32Array
|
||||
>Float32Array : Float32ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...float32Array];
|
||||
>[...float32Array] : number[]
|
||||
>...float32Array : number
|
||||
>float32Array : Float32Array
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
>float64Array : Float64Array
|
||||
>new Float64Array(1) : Float64Array
|
||||
>Float64Array : Float64ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...float64Array];
|
||||
>[...float64Array] : number[]
|
||||
>...float64Array : number
|
||||
>float64Array : Float64Array
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
>int16Array : Int16Array
|
||||
>new Int16Array(1) : Int16Array
|
||||
>Int16Array : Int16ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...int16Array];
|
||||
>[...int16Array] : number[]
|
||||
>...int16Array : number
|
||||
>int16Array : Int16Array
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
>int32Array : Int32Array
|
||||
>new Int32Array(1) : Int32Array
|
||||
>Int32Array : Int32ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...int32Array];
|
||||
>[...int32Array] : number[]
|
||||
>...int32Array : number
|
||||
>int32Array : Int32Array
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
>int8Array : Int8Array
|
||||
>new Int8Array(1) : Int8Array
|
||||
>Int8Array : Int8ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...int8Array];
|
||||
>[...int8Array] : number[]
|
||||
>...int8Array : number
|
||||
>int8Array : Int8Array
|
||||
|
||||
const nodeList = new NodeList();
|
||||
>nodeList : NodeList
|
||||
>new NodeList() : NodeList
|
||||
>NodeList : { new (): NodeList; prototype: NodeList; }
|
||||
|
||||
[...nodeList];
|
||||
>[...nodeList] : Node[]
|
||||
>...nodeList : Node
|
||||
>nodeList : NodeList
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
>uint16Array : Uint16Array
|
||||
>new Uint16Array(1) : Uint16Array
|
||||
>Uint16Array : Uint16ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint16Array];
|
||||
>[...uint16Array] : number[]
|
||||
>...uint16Array : number
|
||||
>uint16Array : Uint16Array
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
>uint32Array : Uint32Array
|
||||
>new Uint32Array(1) : Uint32Array
|
||||
>Uint32Array : Uint32ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint32Array];
|
||||
>[...uint32Array] : number[]
|
||||
>...uint32Array : number
|
||||
>uint32Array : Uint32Array
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
>uint8Array : Uint8Array
|
||||
>new Uint8Array(1) : Uint8Array
|
||||
>Uint8Array : Uint8ArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint8Array];
|
||||
>[...uint8Array] : number[]
|
||||
>...uint8Array : number
|
||||
>uint8Array : Uint8Array
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
>uint8ClampedArray : Uint8ClampedArray
|
||||
>new Uint8ClampedArray(1) : Uint8ClampedArray
|
||||
>Uint8ClampedArray : Uint8ClampedArrayConstructor
|
||||
>1 : 1
|
||||
|
||||
[...uint8ClampedArray];
|
||||
>[...uint8ClampedArray] : number[]
|
||||
>...uint8ClampedArray : number
|
||||
>uint8ClampedArray : Uint8ClampedArray
|
||||
|
||||
33
tests/cases/compiler/typedArrays-es5.ts
Normal file
33
tests/cases/compiler/typedArrays-es5.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// @target: ES5
|
||||
|
||||
const float32Array = new Float32Array(1);
|
||||
[...float32Array];
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
[...float64Array];
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
[...int16Array];
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
[...int32Array];
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
[...int8Array];
|
||||
|
||||
const nodeList = new NodeList();
|
||||
[...nodeList];
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
[...uint16Array];
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
[...uint32Array];
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
[...uint8Array];
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
[...uint8ClampedArray];
|
||||
|
||||
|
||||
31
tests/cases/compiler/typedArrays-es6.ts
Normal file
31
tests/cases/compiler/typedArrays-es6.ts
Normal file
@ -0,0 +1,31 @@
|
||||
// @target: ES6
|
||||
|
||||
const float32Array = new Float32Array(1);
|
||||
[...float32Array];
|
||||
|
||||
const float64Array = new Float64Array(1);
|
||||
[...float64Array];
|
||||
|
||||
const int16Array = new Int16Array(1);
|
||||
[...int16Array];
|
||||
|
||||
const int32Array = new Int32Array(1);
|
||||
[...int32Array];
|
||||
|
||||
const int8Array = new Int8Array(1);
|
||||
[...int8Array];
|
||||
|
||||
const nodeList = new NodeList();
|
||||
[...nodeList];
|
||||
|
||||
const uint16Array = new Uint16Array(1);
|
||||
[...uint16Array];
|
||||
|
||||
const uint32Array = new Uint32Array(1);
|
||||
[...uint32Array];
|
||||
|
||||
const uint8Array = new Uint8Array(1);
|
||||
[...uint8Array];
|
||||
|
||||
const uint8ClampedArray = new Uint8ClampedArray(1);
|
||||
[...uint8ClampedArray];
|
||||
Loading…
x
Reference in New Issue
Block a user