mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 22:55:36 -05:00
Update tests and baselines
This commit is contained in:
@@ -7,20 +7,20 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322
|
||||
Property 's' is missing in type '{ b: boolean; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,11): error TS2339: Property 'length' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,11): error TS2339: Property 'charAt' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(54,11): error TS2339: Property 'a' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(75,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,11): error TS2339: Property 'length' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,11): error TS2339: Property 'charAt' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,12): error TS2339: Property 'b' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,11): error TS2339: Property 'a' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(73,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
|
||||
Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(76,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
|
||||
Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
|
||||
Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
|
||||
Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ====
|
||||
@@ -69,9 +69,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322
|
||||
!!! error TS2300: Duplicate identifier 'b'.
|
||||
let duplicatedSpread = { ...o, ...o }
|
||||
|
||||
// primitives are not allowed
|
||||
let spreadNum = { ...12 };
|
||||
let spreadSum = { ...1 + 1 };
|
||||
// primitives are skipped
|
||||
let spreadStr = { ...'foo' };
|
||||
spreadStr.length; // error, no 'length'
|
||||
~~~~~~
|
||||
|
||||
@@ -29,9 +29,7 @@ spread = b; // error, missing 's'
|
||||
let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' }
|
||||
let duplicatedSpread = { ...o, ...o }
|
||||
|
||||
// primitives are not allowed
|
||||
let spreadNum = { ...12 };
|
||||
let spreadSum = { ...1 + 1 };
|
||||
// primitives are skipped
|
||||
let spreadStr = { ...'foo' };
|
||||
spreadStr.length; // error, no 'length'
|
||||
spreadStr.charAt(1); // error, no methods either
|
||||
@@ -118,9 +116,7 @@ spread = b; // error, missing 's'
|
||||
// literal repeats are not allowed, but spread repeats are fine
|
||||
var duplicated = __assign({ b: 'bad' }, o, { b: 'bad' }, o2, { b: 'bad' });
|
||||
var duplicatedSpread = __assign({}, o, o);
|
||||
// primitives are not allowed
|
||||
var spreadNum = __assign({}, 12);
|
||||
var spreadSum = __assign({}, 1 + 1);
|
||||
// primitives are skipped
|
||||
var spreadStr = __assign({}, 'foo');
|
||||
spreadStr.length; // error, no 'length'
|
||||
spreadStr.charAt(1); // error, no methods either
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(33,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(35,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(36,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(38,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(41,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(42,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(44,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(45,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(47,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(48,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(55,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(56,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(18,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(20,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(22,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(23,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(25,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(28,13): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types may only be created from object types.
|
||||
|
||||
|
||||
==== tests/cases/compiler/restInvalidArgumentType.ts (14 errors) ====
|
||||
enum E { v1, v2 };
|
||||
|
||||
==== tests/cases/compiler/restInvalidArgumentType.ts (7 errors) ====
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
@@ -27,24 +18,13 @@ tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var {...r1} = p1; // Error, generic type paramterre
|
||||
~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
@@ -68,37 +48,14 @@ tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types
|
||||
var {...r8} = union_generic; // Error, union with generic type parameter
|
||||
~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
var {...r9} = union_primitive; // Error, union with generic type parameter
|
||||
~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
|
||||
var {...r10} = intersection_generic; // Error, intersection with generic type parameter
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
var {...r11} = intersection_premitive; // Error, intersection with generic type parameter
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
|
||||
var {...r12} = num; // Error
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
var {...r13} = str; // Error
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
|
||||
var {...r14} = u; // OK
|
||||
var {...r15} = n; // OK
|
||||
|
||||
var {...r16} = a; // OK
|
||||
|
||||
var {...r17} = literal_string; // Error
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
var {...r18} = literal_number; // Error
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
|
||||
var {...r19} = e; // Error, enum
|
||||
~~~
|
||||
!!! error TS2700: Rest types may only be created from object types.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//// [restInvalidArgumentType.ts]
|
||||
enum E { v1, v2 };
|
||||
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
@@ -11,24 +9,13 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var {...r1} = p1; // Error, generic type paramterre
|
||||
var {...r2} = p2; // OK
|
||||
var {...r3} = t; // Error, generic type paramter
|
||||
@@ -40,24 +27,15 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var {...r7} = mapped; // OK, non-generic mapped type
|
||||
|
||||
var {...r8} = union_generic; // Error, union with generic type parameter
|
||||
var {...r9} = union_primitive; // Error, union with generic type parameter
|
||||
|
||||
var {...r10} = intersection_generic; // Error, intersection with generic type parameter
|
||||
var {...r11} = intersection_premitive; // Error, intersection with generic type parameter
|
||||
|
||||
var {...r12} = num; // Error
|
||||
var {...r13} = str; // Error
|
||||
|
||||
var {...r14} = u; // OK
|
||||
var {...r15} = n; // OK
|
||||
|
||||
var {...r16} = a; // OK
|
||||
|
||||
var {...r17} = literal_string; // Error
|
||||
var {...r18} = literal_number; // Error
|
||||
|
||||
var {...r19} = e; // Error, enum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [restInvalidArgumentType.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
@@ -69,12 +47,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
||||
t[p[i]] = s[p[i]];
|
||||
return t;
|
||||
};
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["v1"] = 0] = "v1";
|
||||
E[E["v2"] = 1] = "v2";
|
||||
})(E || (E = {}));
|
||||
;
|
||||
function f(p1, p2) {
|
||||
var t;
|
||||
var i;
|
||||
@@ -82,17 +54,10 @@ function f(p1, p2) {
|
||||
var mapped_generic;
|
||||
var mapped;
|
||||
var union_generic;
|
||||
var union_primitive;
|
||||
var intersection_generic;
|
||||
var intersection_premitive;
|
||||
var num;
|
||||
var str;
|
||||
var u;
|
||||
var n;
|
||||
var a;
|
||||
var literal_string;
|
||||
var literal_number;
|
||||
var e;
|
||||
var r1 = __rest(p1, []); // Error, generic type paramterre
|
||||
var r2 = __rest(p2, []); // OK
|
||||
var r3 = __rest(t, []); // Error, generic type paramter
|
||||
@@ -101,15 +66,8 @@ function f(p1, p2) {
|
||||
var r6 = __rest(mapped_generic, []); // Error, generic mapped object type
|
||||
var r7 = __rest(mapped, []); // OK, non-generic mapped type
|
||||
var r8 = __rest(union_generic, []); // Error, union with generic type parameter
|
||||
var r9 = __rest(union_primitive, []); // Error, union with generic type parameter
|
||||
var r10 = __rest(intersection_generic, []); // Error, intersection with generic type parameter
|
||||
var r11 = __rest(intersection_premitive, []); // Error, intersection with generic type parameter
|
||||
var r12 = __rest(num, []); // Error
|
||||
var r13 = __rest(str, []); // Error
|
||||
var r14 = __rest(u, []); // OK
|
||||
var r15 = __rest(n, []); // OK
|
||||
var r16 = __rest(a, []); // OK
|
||||
var r17 = __rest(literal_string, []); // Error
|
||||
var r18 = __rest(literal_number, []); // Error
|
||||
var r19 = __rest(e, []); // Error, enum
|
||||
}
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(31,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(33,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(35,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(36,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(38,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(41,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(42,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(44,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(45,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(47,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(48,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(56,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(19,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(21,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(23,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(24,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(26,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(29,16): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread types may only be created from object types.
|
||||
|
||||
|
||||
==== tests/cases/compiler/spreadInvalidArgumentType.ts (14 errors) ====
|
||||
enum E { v1, v2 };
|
||||
|
||||
==== tests/cases/compiler/spreadInvalidArgumentType.ts (7 errors) ====
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
@@ -27,24 +18,14 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread t
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var o1 = { ...p1 }; // Error, generic type paramterre
|
||||
~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
@@ -68,37 +49,14 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread t
|
||||
var o8 = { ...union_generic }; // Error, union with generic type parameter
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
var o9 = { ...union_primitive }; // Error, union with generic type parameter
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
|
||||
var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
|
||||
var o12 = { ...num }; // Error
|
||||
~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
var o13 = { ...str }; // Error
|
||||
~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
|
||||
var o14 = { ...u }; // OK
|
||||
var o15 = { ...n }; // OK
|
||||
|
||||
var o16 = { ...a }; // OK
|
||||
|
||||
var o17 = { ...literal_string }; // Error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
var o18 = { ...literal_number }; // Error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
|
||||
var o19 = { ...e }; // Error, enum
|
||||
~~~~
|
||||
!!! error TS2698: Spread types may only be created from object types.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//// [spreadInvalidArgumentType.ts]
|
||||
enum E { v1, v2 };
|
||||
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
@@ -11,24 +9,14 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var o1 = { ...p1 }; // Error, generic type paramterre
|
||||
var o2 = { ...p2 }; // OK
|
||||
var o3 = { ...t }; // Error, generic type paramter
|
||||
@@ -40,24 +28,15 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var o7 = { ...mapped }; // OK, non-generic mapped type
|
||||
|
||||
var o8 = { ...union_generic }; // Error, union with generic type parameter
|
||||
var o9 = { ...union_primitive }; // Error, union with generic type parameter
|
||||
|
||||
var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter
|
||||
var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter
|
||||
|
||||
var o12 = { ...num }; // Error
|
||||
var o13 = { ...str }; // Error
|
||||
|
||||
var o14 = { ...u }; // OK
|
||||
var o15 = { ...n }; // OK
|
||||
|
||||
var o16 = { ...a }; // OK
|
||||
|
||||
var o17 = { ...literal_string }; // Error
|
||||
var o18 = { ...literal_number }; // Error
|
||||
|
||||
var o19 = { ...e }; // Error, enum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [spreadInvalidArgumentType.js]
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
@@ -68,12 +47,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["v1"] = 0] = "v1";
|
||||
E[E["v2"] = 1] = "v2";
|
||||
})(E || (E = {}));
|
||||
;
|
||||
function f(p1, p2) {
|
||||
var t;
|
||||
var i;
|
||||
@@ -81,17 +54,10 @@ function f(p1, p2) {
|
||||
var mapped_generic;
|
||||
var mapped;
|
||||
var union_generic;
|
||||
var union_primitive;
|
||||
var intersection_generic;
|
||||
var intersection_premitive;
|
||||
var num;
|
||||
var str;
|
||||
var u;
|
||||
var n;
|
||||
var a;
|
||||
var literal_string;
|
||||
var literal_number;
|
||||
var e;
|
||||
var o1 = __assign({}, p1); // Error, generic type paramterre
|
||||
var o2 = __assign({}, p2); // OK
|
||||
var o3 = __assign({}, t); // Error, generic type paramter
|
||||
@@ -100,15 +66,8 @@ function f(p1, p2) {
|
||||
var o6 = __assign({}, mapped_generic); // Error, generic mapped object type
|
||||
var o7 = __assign({}, mapped); // OK, non-generic mapped type
|
||||
var o8 = __assign({}, union_generic); // Error, union with generic type parameter
|
||||
var o9 = __assign({}, union_primitive); // Error, union with generic type parameter
|
||||
var o10 = __assign({}, intersection_generic); // Error, intersection with generic type parameter
|
||||
var o11 = __assign({}, intersection_premitive); // Error, intersection with generic type parameter
|
||||
var o12 = __assign({}, num); // Error
|
||||
var o13 = __assign({}, str); // Error
|
||||
var o14 = __assign({}, u); // OK
|
||||
var o15 = __assign({}, n); // OK
|
||||
var o16 = __assign({}, a); // OK
|
||||
var o17 = __assign({}, literal_string); // Error
|
||||
var o18 = __assign({}, literal_number); // Error
|
||||
var o19 = __assign({}, e); // Error, enum
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
enum E { v1, v2 };
|
||||
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
@@ -10,24 +8,13 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var {...r1} = p1; // Error, generic type paramterre
|
||||
var {...r2} = p2; // OK
|
||||
var {...r3} = t; // Error, generic type paramter
|
||||
@@ -39,21 +26,11 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var {...r7} = mapped; // OK, non-generic mapped type
|
||||
|
||||
var {...r8} = union_generic; // Error, union with generic type parameter
|
||||
var {...r9} = union_primitive; // Error, union with generic type parameter
|
||||
|
||||
var {...r10} = intersection_generic; // Error, intersection with generic type parameter
|
||||
var {...r11} = intersection_premitive; // Error, intersection with generic type parameter
|
||||
|
||||
var {...r12} = num; // Error
|
||||
var {...r13} = str; // Error
|
||||
|
||||
var {...r14} = u; // OK
|
||||
var {...r15} = n; // OK
|
||||
|
||||
var {...r16} = a; // OK
|
||||
|
||||
var {...r17} = literal_string; // Error
|
||||
var {...r18} = literal_number; // Error
|
||||
|
||||
var {...r19} = e; // Error, enum
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
enum E { v1, v2 };
|
||||
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
@@ -10,24 +8,14 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var o1 = { ...p1 }; // Error, generic type paramterre
|
||||
var o2 = { ...p2 }; // OK
|
||||
var o3 = { ...t }; // Error, generic type paramter
|
||||
@@ -39,21 +27,11 @@ function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var o7 = { ...mapped }; // OK, non-generic mapped type
|
||||
|
||||
var o8 = { ...union_generic }; // Error, union with generic type parameter
|
||||
var o9 = { ...union_primitive }; // Error, union with generic type parameter
|
||||
|
||||
var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter
|
||||
var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter
|
||||
|
||||
var o12 = { ...num }; // Error
|
||||
var o13 = { ...str }; // Error
|
||||
|
||||
var o14 = { ...u }; // OK
|
||||
var o15 = { ...n }; // OK
|
||||
|
||||
var o16 = { ...a }; // OK
|
||||
|
||||
var o17 = { ...literal_string }; // Error
|
||||
var o18 = { ...literal_number }; // Error
|
||||
|
||||
var o19 = { ...e }; // Error, enum
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ spread = b; // error, missing 's'
|
||||
let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' }
|
||||
let duplicatedSpread = { ...o, ...o }
|
||||
|
||||
// primitives are not allowed
|
||||
let spreadNum = { ...12 };
|
||||
let spreadSum = { ...1 + 1 };
|
||||
// primitives are skipped
|
||||
let spreadStr = { ...'foo' };
|
||||
spreadStr.length; // error, no 'length'
|
||||
spreadStr.charAt(1); // error, no methods either
|
||||
|
||||
Reference in New Issue
Block a user