示例工程 13-declaration-files

13-declaration-files/01-ambient-declaration/lib/legacy-math.js

javascript · 0.2 KB

运行:13 · ambient-declaration

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

// 一个没有类型声明的老式全局库:脚本加载后挂在 globalThis 上
globalThis.LegacyMath = {
  version: '1.0.0',
  add(a, b) {
    return a + b;
  },
};