示例工程 30-web-components-types

30-web-components-types/04-observed-attributes/types.test-d.ts

typescript · 0.3 KB

运行:30 · observed-attributes

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

type Equal<A, B> =
  (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
type Expect<T extends true> = T;
 
import { XGreeting } from './src/main.js';
 
type Case1 = Expect<Equal<typeof XGreeting.observedAttributes, string[]>>;
type Case2 = Expect<Equal<XGreeting extends HTMLElement ? true : false, true>>;