mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 04:01:39 +03:00
27 lines
305 B
TypeScript
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
|
|
}
|