Add property access and --noImplicitAny tests

And update baselines
This commit is contained in:
Nathan Shively-Sanders 2016-11-30 13:14:52 -08:00
parent f6ace2d83d
commit 8e648f9f6d
7 changed files with 34 additions and 9 deletions

View File

@ -37,7 +37,7 @@ let computed2 = 'a';
var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o);
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
//// [objectRest.js]
@ -80,6 +80,6 @@ var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __re
(_j = computed, stillNotGreat = o[_j], _k = computed2, soSo = o[_k], o = __rest(o, [typeof _j === "symbol" ? _j : _j + "", typeof _k === "symbol" ? _k : _k + ""]));
var noContextualType = (_a) => {
var { aNumber = 12 } = _a, notEmptyObject = __rest(_a, ["aNumber"]);
return aNumber;
return aNumber + notEmptyObject.anythingGoes;
};
var _d, _f, _j, _k;

View File

@ -169,9 +169,10 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51))
>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51))
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
>noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 38, 3))
>aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25))
>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39))
>aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25))
>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39))

View File

@ -195,11 +195,15 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
>o : { a: number; b: string; }
>o : { a: number; b: string; }
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
>noContextualType : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => number
>({ aNumber = 12, ...notEmptyObject }) => aNumber : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => number
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
>noContextualType : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any
>({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any
>aNumber : number
>12 : 12
>notEmptyObject : { [x: string]: any; }
>notEmptyObject : any
>aNumber + notEmptyObject.anythingGoes : any
>aNumber : number
>notEmptyObject.anythingGoes : any
>notEmptyObject : any
>anythingGoes : any

View File

@ -3,11 +3,14 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(6,10): error TS2322: Ty
Types of property 'a' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/rest/objectRestNegative.ts(9,31): error TS2462: A rest element must be last in a destructuring pattern
tests/cases/conformance/types/rest/objectRestNegative.ts(11,30): error TS7008: Member 'x' implicitly has an 'any' type.
tests/cases/conformance/types/rest/objectRestNegative.ts(11,33): error TS7008: Member 'y' implicitly has an 'any' type.
tests/cases/conformance/types/rest/objectRestNegative.ts(12,17): error TS2700: Rest types may only be created from object types.
tests/cases/conformance/types/rest/objectRestNegative.ts(17,9): error TS2701: The target of an object rest assignment must be a variable or a property access.
tests/cases/conformance/types/rest/objectRestNegative.ts(19,44): error TS7031: Binding element 'implicitlyAny' implicitly has an 'any' type.
==== tests/cases/conformance/types/rest/objectRestNegative.ts (5 errors) ====
==== tests/cases/conformance/types/rest/objectRestNegative.ts (8 errors) ====
let o = { a: 1, b: 'no' };
var { ...mustBeLast, a } = o;
~~~~~~~~~~
@ -27,6 +30,10 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(17,9): error TS2701: Th
!!! error TS2462: A rest element must be last in a destructuring pattern
}
function generic<T extends { x, y }>(t: T) {
~~
!!! error TS7008: Member 'x' implicitly has an 'any' type.
~
!!! error TS7008: Member 'y' implicitly has an 'any' type.
let { x, ...rest } = t;
~~~~
!!! error TS2700: Rest types may only be created from object types.
@ -37,4 +44,8 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(17,9): error TS2701: Th
({a, ...rest.b + rest.b} = o);
~~~~~~~~~~~~~~~
!!! error TS2701: The target of an object rest assignment must be a variable or a property access.
var noContextualType = ({ aNumber = 12, ...implicitlyAny }) => aNumber + implicitlyAny.anythingGoes;
~~~~~~~~~~~~~
!!! error TS7031: Binding element 'implicitlyAny' implicitly has an 'any' type.

View File

@ -16,6 +16,8 @@ function generic<T extends { x, y }>(t: T) {
let rest: { b: string }
({a, ...rest.b + rest.b} = o);
var noContextualType = ({ aNumber = 12, ...implicitlyAny }) => aNumber + implicitlyAny.anythingGoes;
//// [objectRestNegative.js]
@ -42,3 +44,7 @@ function generic(t) {
}
var rest;
(a = o.a, o, rest.b + rest.b = __rest(o, ["a"]));
var noContextualType = function (_a) {
var _b = _a.aNumber, aNumber = _b === void 0 ? 12 : _b, implicitlyAny = __rest(_a, ["aNumber"]);
return aNumber + implicitlyAny.anythingGoes;
};

View File

@ -37,4 +37,4 @@ let computed2 = 'a';
var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o);
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;

View File

@ -1,3 +1,4 @@
// @noImplicitAny: true
let o = { a: 1, b: 'no' };
var { ...mustBeLast, a } = o;
@ -15,3 +16,5 @@ function generic<T extends { x, y }>(t: T) {
let rest: { b: string }
({a, ...rest.b + rest.b} = o);
var noContextualType = ({ aNumber = 12, ...implicitlyAny }) => aNumber + implicitlyAny.anythingGoes;