mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
Merge pull request #25565 from Microsoft/popFirst
Make 'pop' the first method that uses 'T' in 'Array'
This commit is contained in:
8
src/lib/es5.d.ts
vendored
8
src/lib/es5.d.ts
vendored
@@ -1125,15 +1125,15 @@ interface Array<T> {
|
||||
* Returns a string representation of an array. The elements are converted to string using their toLocalString methods.
|
||||
*/
|
||||
toLocaleString(): string;
|
||||
/**
|
||||
* Removes the last element from an array and returns it.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* Appends new elements to an array, and returns the new length of the array.
|
||||
* @param items New elements of the Array.
|
||||
*/
|
||||
push(...items: T[]): number;
|
||||
/**
|
||||
* Removes the last element from an array and returns it.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* Combines two or more arrays.
|
||||
* @param items Additional items to add to the end of array1.
|
||||
|
||||
@@ -21,7 +21,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error
|
||||
Types of property '0' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'.
|
||||
Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '2' is not assignable to type '1'.
|
||||
@@ -29,14 +29,14 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error
|
||||
Types of property 'length' are incompatible.
|
||||
Type '2' is not assignable to type '1'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string]'.
|
||||
Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(31,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'.
|
||||
Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (19 errors) ====
|
||||
@@ -102,7 +102,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
|
||||
var l3: [number] = z;
|
||||
~~
|
||||
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
var m1: [string] = x;
|
||||
~~
|
||||
!!! error TS2322: Type '[string, number]' is not assignable to type '[string]'.
|
||||
@@ -116,7 +116,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
|
||||
var m3: [string] = z;
|
||||
~~
|
||||
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
var n1: [number, string] = x;
|
||||
~~
|
||||
!!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'.
|
||||
@@ -129,7 +129,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
|
||||
var n3: [number, string] = z;
|
||||
~~
|
||||
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'.
|
||||
var o1: [string, number] = x;
|
||||
var o2: [string, number] = y;
|
||||
var o3: [string, number] = y;
|
||||
|
||||
@@ -34,7 +34,7 @@ tests/cases/compiler/arrayAssignmentTest1.ts(77,1): error TS2322: Type 'I1[]' is
|
||||
Type 'I1' is not assignable to type 'C3'.
|
||||
Property 'CM3M1' is missing in type 'I1'.
|
||||
tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'.
|
||||
Property 'push' is missing in type '() => C1'.
|
||||
Property 'pop' is missing in type '() => C1'.
|
||||
tests/cases/compiler/arrayAssignmentTest1.ts(80,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'.
|
||||
Property 'length' is missing in type '{ one: number; }'.
|
||||
tests/cases/compiler/arrayAssignmentTest1.ts(82,1): error TS2322: Type 'C1' is not assignable to type 'any[]'.
|
||||
@@ -177,7 +177,7 @@ tests/cases/compiler/arrayAssignmentTest1.ts(85,1): error TS2322: Type 'I1' is n
|
||||
arr_any = f1; // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '() => C1' is not assignable to type 'any[]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '() => C1'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '() => C1'.
|
||||
arr_any = o1; // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'.
|
||||
|
||||
@@ -8,9 +8,9 @@ tests/cases/compiler/arrayAssignmentTest2.ts(49,1): error TS2322: Type 'I1[]' is
|
||||
Type 'I1' is not assignable to type 'C3'.
|
||||
Property 'CM3M1' is missing in type 'I1'.
|
||||
tests/cases/compiler/arrayAssignmentTest2.ts(51,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'.
|
||||
Property 'push' is missing in type '() => C1'.
|
||||
Property 'pop' is missing in type '() => C1'.
|
||||
tests/cases/compiler/arrayAssignmentTest2.ts(52,1): error TS2322: Type '() => any' is not assignable to type 'any[]'.
|
||||
Property 'push' is missing in type '() => any'.
|
||||
Property 'pop' is missing in type '() => any'.
|
||||
tests/cases/compiler/arrayAssignmentTest2.ts(53,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'.
|
||||
Property 'length' is missing in type '{ one: number; }'.
|
||||
tests/cases/compiler/arrayAssignmentTest2.ts(55,1): error TS2322: Type 'C1' is not assignable to type 'any[]'.
|
||||
@@ -89,11 +89,11 @@ tests/cases/compiler/arrayAssignmentTest2.ts(58,1): error TS2322: Type 'I1' is n
|
||||
arr_any = f1; // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '() => C1' is not assignable to type 'any[]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '() => C1'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '() => C1'.
|
||||
arr_any = function () { return null;} // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '() => any' is not assignable to type 'any[]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '() => any'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '() => any'.
|
||||
arr_any = o1; // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/arrayAssignmentTest4.ts(22,1): error TS2322: Type '() => any' is not assignable to type 'any[]'.
|
||||
Property 'push' is missing in type '() => any'.
|
||||
Property 'pop' is missing in type '() => any'.
|
||||
tests/cases/compiler/arrayAssignmentTest4.ts(23,1): error TS2322: Type 'C3' is not assignable to type 'any[]'.
|
||||
Property 'length' is missing in type 'C3'.
|
||||
|
||||
@@ -29,7 +29,7 @@ tests/cases/compiler/arrayAssignmentTest4.ts(23,1): error TS2322: Type 'C3' is n
|
||||
arr_any = function () { return null;} // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '() => any' is not assignable to type 'any[]'.
|
||||
!!! error TS2322: Property 'push' is missing in type '() => any'.
|
||||
!!! error TS2322: Property 'pop' is missing in type '() => any'.
|
||||
arr_any = c3; // should be an error - is
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'C3' is not assignable to type 'any[]'.
|
||||
|
||||
@@ -11,12 +11,10 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
Types of property 'push' are incompatible.
|
||||
Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
Types of parameters 'items' and 'items' are incompatible.
|
||||
Type 'Number' is not assignable to type 'string | number'.
|
||||
Type 'Number' is not assignable to type 'number'.
|
||||
'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => Number'.
|
||||
Type 'string | number' is not assignable to type 'Number'.
|
||||
Type 'string' is not assignable to type 'Number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (8 errors) ====
|
||||
@@ -75,10 +73,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[]
|
||||
~~
|
||||
!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
!!! error TS2322: Types of property 'push' are incompatible.
|
||||
!!! error TS2322: Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
|
||||
!!! error TS2322: Type 'Number' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type 'Number' is not assignable to type 'number'.
|
||||
!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number' is not assignable to type '() => Number'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
||||
|
||||
@@ -88,7 +88,7 @@ type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
|
||||
>Shape : Shape
|
||||
|
||||
type K11 = keyof Shape[]; // "length" | "toString" | ...
|
||||
>K11 : number | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>K11 : number | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>Shape : Shape
|
||||
|
||||
type K12 = keyof Dictionary<Shape>; // string
|
||||
@@ -108,7 +108,7 @@ type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>E : E
|
||||
|
||||
type K16 = keyof [string, number]; // "0" | "1" | "length" | "toString" | ...
|
||||
>K16 : number | "0" | "1" | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>K16 : number | "0" | "1" | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
|
||||
type K17 = keyof (Shape | Item); // "name"
|
||||
>K17 : "name"
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts(10,9): error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'Style'.
|
||||
Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'StyleArray'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => { foo: string; jj: number; }[][]' is not assignable to type '() => Style'.
|
||||
Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'.
|
||||
Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => { foo: string; jj: number; }[]' is not assignable to type '() => Style'.
|
||||
Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'.
|
||||
Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => { foo: string; jj: number; }' is not assignable to type '() => Style'.
|
||||
Type '{ foo: string; jj: number; }' is not assignable to type 'Style'.
|
||||
Object literal may only specify known properties, and 'jj' does not exist in type 'Style'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts (1 errors) ====
|
||||
type Style = StyleBase | StyleArray;
|
||||
interface StyleArray extends Array<Style> {}
|
||||
interface StyleBase {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
const blah: Style = [
|
||||
[[{
|
||||
foo: 'asdf',
|
||||
jj: 1 // intentional error
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'Style'.
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'StyleArray'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => { foo: string; jj: number; }[][]' is not assignable to type '() => Style'.
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'.
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => { foo: string; jj: number; }[]' is not assignable to type '() => Style'.
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'.
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => { foo: string; jj: number; }' is not assignable to type '() => Style'.
|
||||
!!! error TS2322: Type '{ foo: string; jj: number; }' is not assignable to type 'Style'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'jj' does not exist in type 'Style'.
|
||||
}]]
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [nestedRecursiveArraysOrObjectsError01.ts]
|
||||
type Style = StyleBase | StyleArray;
|
||||
interface StyleArray extends Array<Style> {}
|
||||
interface StyleBase {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
const blah: Style = [
|
||||
[[{
|
||||
foo: 'asdf',
|
||||
jj: 1 // intentional error
|
||||
}]]
|
||||
];
|
||||
|
||||
|
||||
|
||||
//// [nestedRecursiveArraysOrObjectsError01.js]
|
||||
var blah = [
|
||||
[[{
|
||||
foo: 'asdf',
|
||||
jj: 1 // intentional error
|
||||
}]]
|
||||
];
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts ===
|
||||
type Style = StyleBase | StyleArray;
|
||||
>Style : Symbol(Style, Decl(nestedRecursiveArraysOrObjectsError01.ts, 0, 0))
|
||||
>StyleBase : Symbol(StyleBase, Decl(nestedRecursiveArraysOrObjectsError01.ts, 1, 44))
|
||||
>StyleArray : Symbol(StyleArray, Decl(nestedRecursiveArraysOrObjectsError01.ts, 0, 36))
|
||||
|
||||
interface StyleArray extends Array<Style> {}
|
||||
>StyleArray : Symbol(StyleArray, Decl(nestedRecursiveArraysOrObjectsError01.ts, 0, 36))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Style : Symbol(Style, Decl(nestedRecursiveArraysOrObjectsError01.ts, 0, 0))
|
||||
|
||||
interface StyleBase {
|
||||
>StyleBase : Symbol(StyleBase, Decl(nestedRecursiveArraysOrObjectsError01.ts, 1, 44))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(StyleBase.foo, Decl(nestedRecursiveArraysOrObjectsError01.ts, 2, 21))
|
||||
}
|
||||
|
||||
const blah: Style = [
|
||||
>blah : Symbol(blah, Decl(nestedRecursiveArraysOrObjectsError01.ts, 6, 5))
|
||||
>Style : Symbol(Style, Decl(nestedRecursiveArraysOrObjectsError01.ts, 0, 0))
|
||||
|
||||
[[{
|
||||
foo: 'asdf',
|
||||
>foo : Symbol(foo, Decl(nestedRecursiveArraysOrObjectsError01.ts, 7, 7))
|
||||
|
||||
jj: 1 // intentional error
|
||||
>jj : Symbol(jj, Decl(nestedRecursiveArraysOrObjectsError01.ts, 8, 20))
|
||||
|
||||
}]]
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts ===
|
||||
type Style = StyleBase | StyleArray;
|
||||
>Style : Style
|
||||
>StyleBase : StyleBase
|
||||
>StyleArray : StyleArray
|
||||
|
||||
interface StyleArray extends Array<Style> {}
|
||||
>StyleArray : StyleArray
|
||||
>Array : T[]
|
||||
>Style : Style
|
||||
|
||||
interface StyleBase {
|
||||
>StyleBase : StyleBase
|
||||
|
||||
foo: string;
|
||||
>foo : string
|
||||
}
|
||||
|
||||
const blah: Style = [
|
||||
>blah : Style
|
||||
>Style : Style
|
||||
>[ [[{ foo: 'asdf', jj: 1 // intentional error }]]] : { foo: string; jj: number; }[][][]
|
||||
|
||||
[[{
|
||||
>[[{ foo: 'asdf', jj: 1 // intentional error }]] : { foo: string; jj: number; }[][]
|
||||
>[{ foo: 'asdf', jj: 1 // intentional error }] : { foo: string; jj: number; }[]
|
||||
>{ foo: 'asdf', jj: 1 // intentional error } : { foo: string; jj: number; }
|
||||
|
||||
foo: 'asdf',
|
||||
>foo : string
|
||||
>'asdf' : "asdf"
|
||||
|
||||
jj: 1 // intentional error
|
||||
>jj : number
|
||||
>1 : 1
|
||||
|
||||
}]]
|
||||
];
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
>p1 : T
|
||||
|
||||
var {...r2} = p2; // OK
|
||||
>r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: ConcatArray<T>[]): T[]; concat(...items: (T | ConcatArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray<T>[]): T[]; concat(...items: (T | ConcatArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>p2 : T[]
|
||||
|
||||
var {...r3} = t; // Error, generic type paramter
|
||||
|
||||
@@ -89,8 +89,8 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
>p1 : T
|
||||
|
||||
var o2 = { ...p2 }; // OK
|
||||
>o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: ConcatArray<T>[]): T[]; concat(...items: (T | ConcatArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; push(...items: T[]): number; pop(): T; concat(...items: ConcatArray<T>[]): T[]; concat(...items: (T | ConcatArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray<T>[]): T[]; concat(...items: (T | ConcatArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray<T>[]): T[]; concat(...items: (T | ConcatArray<T>)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }
|
||||
>p2 : T[]
|
||||
|
||||
var o3 = { ...t }; // Error, generic type paramter
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
type Style = StyleBase | StyleArray;
|
||||
interface StyleArray extends Array<Style> {}
|
||||
interface StyleBase {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
const blah: Style = [
|
||||
[[{
|
||||
foo: 'asdf',
|
||||
jj: 1 // intentional error
|
||||
}]]
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user