【发布时间】:2017-05-12 07:03:41
【问题描述】:
这就是我为对象导出和导入 typescript 接口的方式。一切正常。举个例子来说明我想要实现的目标,但要使用功能。
模块 1
export interface MyInterface {
property: string;
}
模块 2
import {MyInterface} from './module1';
const object: MyInterface = {
property: 'some value'
};
下面的代码给了我一个错误“TS2304:找不到名称'myFunction'”。如何导出和导入函数类型?
模块 1
export let myFunction: (argument: string) => void;
模块 2
import {myFunction} from './module1';
let someFunction: myFunction;
【问题讨论】:
-
export type myFunction = (arg: string) => void? -
@Gerrit0,哇哦!谢谢你,先生!有用!如此简单!
-
@Gerrit0 请根据您的评论做出回答,以便其他人也知道。
标签: typescript