Skip to content

Commit 8e648f9

Browse files
committed
Add property access and --noImplicitAny tests
And update baselines
1 parent f6ace2d commit 8e648f9

File tree

7 files changed

+34
-9
lines changed

7 files changed

+34
-9
lines changed

tests/baselines/reference/objectRest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let computed2 = 'a';
3737
var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
3838
({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o);
3939

40-
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
40+
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
4141

4242

4343
//// [objectRest.js]
@@ -80,6 +80,6 @@ var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __re
8080
(_j = computed, stillNotGreat = o[_j], _k = computed2, soSo = o[_k], o = __rest(o, [typeof _j === "symbol" ? _j : _j + "", typeof _k === "symbol" ? _k : _k + ""]));
8181
var noContextualType = (_a) => {
8282
var { aNumber = 12 } = _a, notEmptyObject = __rest(_a, ["aNumber"]);
83-
return aNumber;
83+
return aNumber + notEmptyObject.anythingGoes;
8484
};
8585
var _d, _f, _j, _k;

tests/baselines/reference/objectRest.symbols

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
169169
>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51))
170170
>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51))
171171

172-
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
172+
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
173173
>noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 38, 3))
174174
>aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25))
175175
>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39))
176176
>aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25))
177+
>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39))
177178

tests/baselines/reference/objectRest.types

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,15 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
195195
>o : { a: number; b: string; }
196196
>o : { a: number; b: string; }
197197

198-
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
199-
>noContextualType : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => number
200-
>({ aNumber = 12, ...notEmptyObject }) => aNumber : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => number
198+
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
199+
>noContextualType : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any
200+
>({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any
201201
>aNumber : number
202202
>12 : 12
203-
>notEmptyObject : { [x: string]: any; }
203+
>notEmptyObject : any
204+
>aNumber + notEmptyObject.anythingGoes : any
204205
>aNumber : number
206+
>notEmptyObject.anythingGoes : any
207+
>notEmptyObject : any
208+
>anythingGoes : any
205209

tests/baselines/reference/objectRestNegative.errors.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(6,10): error TS2322: Ty
33
Types of property 'a' are incompatible.
44
Type 'number' is not assignable to type 'string'.
55
tests/cases/conformance/types/rest/objectRestNegative.ts(9,31): error TS2462: A rest element must be last in a destructuring pattern
6+
tests/cases/conformance/types/rest/objectRestNegative.ts(11,30): error TS7008: Member 'x' implicitly has an 'any' type.
7+
tests/cases/conformance/types/rest/objectRestNegative.ts(11,33): error TS7008: Member 'y' implicitly has an 'any' type.
68
tests/cases/conformance/types/rest/objectRestNegative.ts(12,17): error TS2700: Rest types may only be created from object types.
79
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.
10+
tests/cases/conformance/types/rest/objectRestNegative.ts(19,44): error TS7031: Binding element 'implicitlyAny' implicitly has an 'any' type.
811

912

10-
==== tests/cases/conformance/types/rest/objectRestNegative.ts (5 errors) ====
13+
==== tests/cases/conformance/types/rest/objectRestNegative.ts (8 errors) ====
1114
let o = { a: 1, b: 'no' };
1215
var { ...mustBeLast, a } = o;
1316
~~~~~~~~~~
@@ -27,6 +30,10 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(17,9): error TS2701: Th
2730
!!! error TS2462: A rest element must be last in a destructuring pattern
2831
}
2932
function generic<T extends { x, y }>(t: T) {
33+
~~
34+
!!! error TS7008: Member 'x' implicitly has an 'any' type.
35+
~
36+
!!! error TS7008: Member 'y' implicitly has an 'any' type.
3037
let { x, ...rest } = t;
3138
~~~~
3239
!!! 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
3744
({a, ...rest.b + rest.b} = o);
3845
~~~~~~~~~~~~~~~
3946
!!! error TS2701: The target of an object rest assignment must be a variable or a property access.
47+
48+
var noContextualType = ({ aNumber = 12, ...implicitlyAny }) => aNumber + implicitlyAny.anythingGoes;
49+
~~~~~~~~~~~~~
50+
!!! error TS7031: Binding element 'implicitlyAny' implicitly has an 'any' type.
4051

tests/baselines/reference/objectRestNegative.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function generic<T extends { x, y }>(t: T) {
1616

1717
let rest: { b: string }
1818
({a, ...rest.b + rest.b} = o);
19+
20+
var noContextualType = ({ aNumber = 12, ...implicitlyAny }) => aNumber + implicitlyAny.anythingGoes;
1921

2022

2123
//// [objectRestNegative.js]
@@ -42,3 +44,7 @@ function generic(t) {
4244
}
4345
var rest;
4446
(a = o.a, o, rest.b + rest.b = __rest(o, ["a"]));
47+
var noContextualType = function (_a) {
48+
var _b = _a.aNumber, aNumber = _b === void 0 ? 12 : _b, implicitlyAny = __rest(_a, ["aNumber"]);
49+
return aNumber + implicitlyAny.anythingGoes;
50+
};

tests/cases/conformance/types/rest/objectRest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ let computed2 = 'a';
3737
var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
3838
({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o);
3939

40-
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber;
40+
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;

tests/cases/conformance/types/rest/objectRestNegative.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @noImplicitAny: true
12
let o = { a: 1, b: 'no' };
23
var { ...mustBeLast, a } = o;
34

@@ -15,3 +16,5 @@ function generic<T extends { x, y }>(t: T) {
1516

1617
let rest: { b: string }
1718
({a, ...rest.b + rest.b} = o);
19+
20+
var noContextualType = ({ aNumber = 12, ...implicitlyAny }) => aNumber + implicitlyAny.anythingGoes;

0 commit comments

Comments
 (0)