Skip to content

Commit eb06af1

Browse files
committed
Add tests
1 parent 92c17ce commit eb06af1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/cases/conformance/controlFlow/controlFlowTruthiness.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,30 @@ function f6() {
6868
y; // string | undefined
6969
}
7070
}
71+
72+
function f7(x: {}) {
73+
if (x) {
74+
x; // {}
75+
}
76+
else {
77+
x; // {}
78+
}
79+
}
80+
81+
function f8<T>(x: T) {
82+
if (x) {
83+
x; // {}
84+
}
85+
else {
86+
x; // {}
87+
}
88+
}
89+
90+
function f9<T extends object>(x: T) {
91+
if (x) {
92+
x; // {}
93+
}
94+
else {
95+
x; // never
96+
}
97+
}

tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
116116
tk = uj;
117117
uj = tk; // error
118118
}
119+
120+
// The constraint of 'keyof T' is 'keyof T'
121+
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
122+
k = 42; // error
123+
k = "hello"; // error
124+
}

0 commit comments

Comments
 (0)