mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 21:21:31 +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
|
|
}
|