mirror of
https://github.com/swc-project/swc.git
synced 2024-12-29 00:23:10 +03:00
36 lines
701 B
TypeScript
36 lines
701 B
TypeScript
// @declaration: true
|
|
|
|
// Repro from #12513
|
|
|
|
function f1<K extends string, T>(obj: { [P in K]: T }, k: K) {
|
|
const b = k in obj;
|
|
let k1: K;
|
|
for (k1 in obj) {
|
|
let x1 = obj[k1];
|
|
}
|
|
for (let k2 in obj) {
|
|
let x2 = obj[k2];
|
|
}
|
|
}
|
|
|
|
function f2<T>(obj: { [P in keyof T]: T[P] }, k: keyof T) {
|
|
const b = k in obj;
|
|
let k1: keyof T;
|
|
for (k1 in obj) {
|
|
let x1 = obj[k1];
|
|
}
|
|
for (let k2 in obj) {
|
|
let x2 = obj[k2];
|
|
}
|
|
}
|
|
|
|
function f3<T, K extends keyof T>(obj: { [P in K]: T[P] }, k: K) {
|
|
const b = k in obj;
|
|
let k1: K;
|
|
for (k1 in obj) {
|
|
let x1 = obj[k1];
|
|
}
|
|
for (let k2 in obj) {
|
|
let x2 = obj[k2];
|
|
}
|
|
} |