Skip to content

Commit 6ce31d7

Browse files
author
Kanchalai Tanglertsampan
committed
Address comment: stop widen type when checking for spread any;
Address comment: using ternary operator, fix comments
1 parent 350f47a commit 6ce31d7

19 files changed

+76
-84
lines changed

src/compiler/checker.ts

Lines changed: 53 additions & 55 deletions
Large diffs are not rendered by default.

tests/baselines/reference/tsxStatelessFunctionComponentOverload2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let obj2 = {
1818
"ignore-prop": "hello"
1919
}
2020

21-
let defaultObj = undefined;
21+
let defaultObj: any;
2222

2323
// OK
2424
const c1 = <OneThing />
@@ -47,7 +47,7 @@ define(["require", "exports", "react"], function (require, exports, React) {
4747
yy: 500,
4848
"ignore-prop": "hello"
4949
};
50-
var defaultObj = undefined;
50+
var defaultObj;
5151
// OK
5252
var c1 = <OneThing />;
5353
var c2 = <OneThing {...obj}/>;

tests/baselines/reference/tsxStatelessFunctionComponentOverload2.symbols

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ let obj2 = {
4242
"ignore-prop": "hello"
4343
}
4444

45-
let defaultObj = undefined;
45+
let defaultObj: any;
4646
>defaultObj : Symbol(defaultObj, Decl(file.tsx, 19, 3))
47-
>undefined : Symbol(undefined)
4847

4948
// OK
5049
const c1 = <OneThing />

tests/baselines/reference/tsxStatelessFunctionComponentOverload2.types

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ let obj2 = {
5050
>"hello" : "hello"
5151
}
5252

53-
let defaultObj = undefined;
53+
let defaultObj: any;
5454
>defaultObj : any
55-
>undefined : undefined
5655

5756
// OK
5857
const c1 = <OneThing />

tests/baselines/reference/tsxStatelessFunctionComponentOverload3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface Context {
66
declare function ZeroThingOrTwoThing(): JSX.Element;
77
declare function ZeroThingOrTwoThing(l: {yy: number, yy1: string}, context: Context): JSX.Element;
88

9-
let obj2 = undefined;
9+
let obj2: any;
1010

1111
// OK
1212
const two1 = <ZeroThingOrTwoThing />;
@@ -25,7 +25,7 @@ const three2 = <ThreeThing y2="Bye" />;
2525
const three3 = <ThreeThing {...obj2} y2={10} />; // it is just any so we allow it to pass through
2626

2727
//// [file.jsx]
28-
var obj2 = undefined;
28+
var obj2;
2929
// OK
3030
var two1 = <ZeroThingOrTwoThing />;
3131
var two2 = <ZeroThingOrTwoThing yy={100} yy1="hello"/>;

tests/baselines/reference/tsxStatelessFunctionComponentOverload3.symbols

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ declare function ZeroThingOrTwoThing(l: {yy: number, yy1: string}, context: Cont
2121
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
2222
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
2323

24-
let obj2 = undefined;
24+
let obj2: any;
2525
>obj2 : Symbol(obj2, Decl(file.tsx, 7, 3))
26-
>undefined : Symbol(undefined)
2726

2827
// OK
2928
const two1 = <ZeroThingOrTwoThing />;

tests/baselines/reference/tsxStatelessFunctionComponentOverload3.types

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ declare function ZeroThingOrTwoThing(l: {yy: number, yy1: string}, context: Cont
2121
>JSX : any
2222
>Element : JSX.Element
2323

24-
let obj2 = undefined;
24+
let obj2: any;
2525
>obj2 : any
26-
>undefined : undefined
2726

2827
// OK
2928
const two1 = <ZeroThingOrTwoThing />;

tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tests/cases/conformance/jsx/file.tsx(34,29): error TS2322: Type '{ y1: "hello";
4242
yy: 10,
4343
yy1: "hello"
4444
}
45-
let obj2 = undefined;
45+
let obj2: any;
4646

4747
// Error
4848
const c0 = <OneThing extraProp />; // extra property;

tests/baselines/reference/tsxStatelessFunctionComponentOverload4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let obj = {
88
yy: 10,
99
yy1: "hello"
1010
}
11-
let obj2 = undefined;
11+
let obj2: any;
1212

1313
// Error
1414
const c0 = <OneThing extraProp />; // extra property;
@@ -42,7 +42,7 @@ define(["require", "exports", "react"], function (require, exports, React) {
4242
yy: 10,
4343
yy1: "hello"
4444
};
45-
var obj2 = undefined;
45+
var obj2;
4646
// Error
4747
var c0 = <OneThing extraProp/>; // extra property;
4848
var c1 = <OneThing yy={10}/>; // missing property;

tests/baselines/reference/tsxStatelessFunctionComponentOverload5.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ tests/cases/conformance/jsx/file.tsx(57,24): error TS2322: Type '{ data-format:
5252
onClick: ()=>{}
5353
}
5454

55-
let obj3 = undefined;
55+
let obj3: any;
5656

5757
export function MainButton(buttonProps: ButtonProps): JSX.Element;
5858
export function MainButton(linkProps: LinkProps): JSX.Element;

0 commit comments

Comments
 (0)