示例工程 16-js-to-ts-migration
16-js-to-ts-migration/02-allowjs-import/src/main.ts
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
// 演示:TS 文件导入 JS 文件,allowJs 让 JS 参与编译与推断
import { format } from '../js/format.js';
export function run(log: (msg: string) => void = console.log): string[] {
const lines = [format(' ada ')];
for (const line of lines) {
log(line);
}
return lines;
}