-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The falsy part of any/unknown is any/unknown (#39529)
- Loading branch information
1 parent
24832e8
commit dbab46c
Showing
8 changed files
with
231 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/anyAndUnknownHaveFalsyComponents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//// [anyAndUnknownHaveFalsyComponents.ts] | ||
declare let x1: any; | ||
const y1 = x1 && 3; | ||
|
||
// #39113 | ||
declare let isTreeHeader1: any; | ||
function foo1() { | ||
return { | ||
display: "block", | ||
...(isTreeHeader1 && { | ||
display: "flex", | ||
}) | ||
}; | ||
} | ||
|
||
declare let x2: unknown; | ||
const y2 = x2 && 3; | ||
|
||
// #39113 | ||
declare let isTreeHeader2: unknown; | ||
function foo2() { | ||
return { | ||
display: "block", | ||
...(isTreeHeader1 && { | ||
display: "flex", | ||
}) | ||
}; | ||
} | ||
|
||
|
||
//// [anyAndUnknownHaveFalsyComponents.js] | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var y1 = x1 && 3; | ||
function foo1() { | ||
return __assign({ display: "block" }, (isTreeHeader1 && { | ||
display: "flex" | ||
})); | ||
} | ||
var y2 = x2 && 3; | ||
function foo2() { | ||
return __assign({ display: "block" }, (isTreeHeader1 && { | ||
display: "flex" | ||
})); | ||
} |
57 changes: 57 additions & 0 deletions
57
tests/baselines/reference/anyAndUnknownHaveFalsyComponents.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
=== tests/cases/compiler/anyAndUnknownHaveFalsyComponents.ts === | ||
declare let x1: any; | ||
>x1 : Symbol(x1, Decl(anyAndUnknownHaveFalsyComponents.ts, 0, 11)) | ||
|
||
const y1 = x1 && 3; | ||
>y1 : Symbol(y1, Decl(anyAndUnknownHaveFalsyComponents.ts, 1, 5)) | ||
>x1 : Symbol(x1, Decl(anyAndUnknownHaveFalsyComponents.ts, 0, 11)) | ||
|
||
// #39113 | ||
declare let isTreeHeader1: any; | ||
>isTreeHeader1 : Symbol(isTreeHeader1, Decl(anyAndUnknownHaveFalsyComponents.ts, 4, 11)) | ||
|
||
function foo1() { | ||
>foo1 : Symbol(foo1, Decl(anyAndUnknownHaveFalsyComponents.ts, 4, 31)) | ||
|
||
return { | ||
display: "block", | ||
>display : Symbol(display, Decl(anyAndUnknownHaveFalsyComponents.ts, 6, 10)) | ||
|
||
...(isTreeHeader1 && { | ||
>isTreeHeader1 : Symbol(isTreeHeader1, Decl(anyAndUnknownHaveFalsyComponents.ts, 4, 11)) | ||
|
||
display: "flex", | ||
>display : Symbol(display, Decl(anyAndUnknownHaveFalsyComponents.ts, 8, 26)) | ||
|
||
}) | ||
}; | ||
} | ||
|
||
declare let x2: unknown; | ||
>x2 : Symbol(x2, Decl(anyAndUnknownHaveFalsyComponents.ts, 14, 11)) | ||
|
||
const y2 = x2 && 3; | ||
>y2 : Symbol(y2, Decl(anyAndUnknownHaveFalsyComponents.ts, 15, 5)) | ||
>x2 : Symbol(x2, Decl(anyAndUnknownHaveFalsyComponents.ts, 14, 11)) | ||
|
||
// #39113 | ||
declare let isTreeHeader2: unknown; | ||
>isTreeHeader2 : Symbol(isTreeHeader2, Decl(anyAndUnknownHaveFalsyComponents.ts, 18, 11)) | ||
|
||
function foo2() { | ||
>foo2 : Symbol(foo2, Decl(anyAndUnknownHaveFalsyComponents.ts, 18, 35)) | ||
|
||
return { | ||
display: "block", | ||
>display : Symbol(display, Decl(anyAndUnknownHaveFalsyComponents.ts, 20, 10)) | ||
|
||
...(isTreeHeader1 && { | ||
>isTreeHeader1 : Symbol(isTreeHeader1, Decl(anyAndUnknownHaveFalsyComponents.ts, 4, 11)) | ||
|
||
display: "flex", | ||
>display : Symbol(display, Decl(anyAndUnknownHaveFalsyComponents.ts, 22, 26)) | ||
|
||
}) | ||
}; | ||
} | ||
|
75 changes: 75 additions & 0 deletions
75
tests/baselines/reference/anyAndUnknownHaveFalsyComponents.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
=== tests/cases/compiler/anyAndUnknownHaveFalsyComponents.ts === | ||
declare let x1: any; | ||
>x1 : any | ||
|
||
const y1 = x1 && 3; | ||
>y1 : any | ||
>x1 && 3 : any | ||
>x1 : any | ||
>3 : 3 | ||
|
||
// #39113 | ||
declare let isTreeHeader1: any; | ||
>isTreeHeader1 : any | ||
|
||
function foo1() { | ||
>foo1 : () => any | ||
|
||
return { | ||
>{ display: "block", ...(isTreeHeader1 && { display: "flex", }) } : any | ||
|
||
display: "block", | ||
>display : string | ||
>"block" : "block" | ||
|
||
...(isTreeHeader1 && { | ||
>(isTreeHeader1 && { display: "flex", }) : any | ||
>isTreeHeader1 && { display: "flex", } : any | ||
>isTreeHeader1 : any | ||
>{ display: "flex", } : { display: string; } | ||
|
||
display: "flex", | ||
>display : string | ||
>"flex" : "flex" | ||
|
||
}) | ||
}; | ||
} | ||
|
||
declare let x2: unknown; | ||
>x2 : unknown | ||
|
||
const y2 = x2 && 3; | ||
>y2 : unknown | ||
>x2 && 3 : unknown | ||
>x2 : unknown | ||
>3 : 3 | ||
|
||
// #39113 | ||
declare let isTreeHeader2: unknown; | ||
>isTreeHeader2 : unknown | ||
|
||
function foo2() { | ||
>foo2 : () => any | ||
|
||
return { | ||
>{ display: "block", ...(isTreeHeader1 && { display: "flex", }) } : any | ||
|
||
display: "block", | ||
>display : string | ||
>"block" : "block" | ||
|
||
...(isTreeHeader1 && { | ||
>(isTreeHeader1 && { display: "flex", }) : any | ||
>isTreeHeader1 && { display: "flex", } : any | ||
>isTreeHeader1 : any | ||
>{ display: "flex", } : { display: string; } | ||
|
||
display: "flex", | ||
>display : string | ||
>"flex" : "flex" | ||
|
||
}) | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @strictNullChecks: true | ||
|
||
declare let x1: any; | ||
const y1 = x1 && 3; | ||
|
||
// #39113 | ||
declare let isTreeHeader1: any; | ||
function foo1() { | ||
return { | ||
display: "block", | ||
...(isTreeHeader1 && { | ||
display: "flex", | ||
}) | ||
}; | ||
} | ||
|
||
declare let x2: unknown; | ||
const y2 = x2 && 3; | ||
|
||
// #39113 | ||
declare let isTreeHeader2: unknown; | ||
function foo2() { | ||
return { | ||
display: "block", | ||
...(isTreeHeader1 && { | ||
display: "flex", | ||
}) | ||
}; | ||
} |