【发布时间】:2017-05-01 21:09:31
【问题描述】:
所以我为一个模块创建了自己的类型定义:
declare module 'fs-tree-diff' {
interface FSEntry {
relativePath: string;
mode: number;
size: number;
mtime: number;
isDirectory: () => boolean;
}
type Operation = 'unlink' | 'create' | 'mkdir' | 'change' | 'rmdir';
type PatchEntry = [Operation, string, FSEntry];
type Patch = PatchEntry[];
type FSEntries = FSEntry[];
class FSTree {
constructor (options: {entries: FSEntries, sortAndExpand?: boolean});
static fromEntries (entries: FSEntries): FSTree;
static fromPaths (paths: string[]): FSTree;
addEntries (entries: FSEntries, options: {sortAndExpand: boolean}): void;
addPath (paths: string[], options: {sortAndExpand: boolean}): void;
forEach (fn: any, context: any): void;
calculatePatch (other: FSTree, isEqual?: (a: FSEntry, b: FSEntry) => boolean): Patch;
}
export = FSTree;
}
所以现在,我可以在任何地方这样做:
import FSTree = require('fs-tree-diff');
const tree = new FSTree({entries: []});
它有效!但我希望现在能够做到
import FSTree = require('fs-tree-diff');
const tree = new FSTree({entries: []});
let entry: FSTree.FSEntry;
...
如果我尝试在我的模块声明中的每个type 之前添加export,它会在export = ... 的末尾说它不能与其他导出一起导出。如何从另一个文件访问我的 defs?
【问题讨论】:
标签: typescript