示例工程 13-declaration-files
13-declaration-files/01-ambient-declaration/types/legacy-math.d.ts
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
// 为上面的 JS 手写声明:全局脚本,不能有顶层 export
interface LegacyMathApi {
readonly version: string;
add(a: number, b: number): number;
}
declare const LegacyMath: LegacyMathApi;