swc/crates/swc_ecma_parser/tests/tsc/controlFlowInOperator.ts
2022-02-04 17:08:38 +09:00

27 lines
305 B
TypeScript

const a = 'a';
const b = 'b';
const d = 'd';
type A = { [a]: number; };
type B = { [b]: string; };
declare const c: A | B;
if ('a' in c) {
c; // A
c['a']; // number;
}
if ('d' in c) {
c; // never
}
if (a in c) {
c; // A
c[a]; // number;
}
if (d in c) {
c; // never
}