【发布时间】:2019-01-15 16:28:32
【问题描述】:
现在可能不需要Typescript的三斜杠引用,但我还是想知道怎么用。
假设我有两个文件:
--模块/ad.ts
export declare function hello(name: any): void;
-- 模块/a.js
"use strict";
exports.__esModule = true;
function hello(name) {
console.log("Hello, " + name + " (from a)");
}
exports.hello = hello;
现在我想在另一个打字稿文件中使用它:
你好.ts
/// <reference path="./modules/a.d.ts" />
hello("module a");
我是这样写的,但是编译hello.ts的时候报错:
hello.ts(3,1): error TS2304: Cannot find name 'hello'.
我该如何解决?
【问题讨论】:
标签: typescript import module