Also machte ich meine eigene Art def für ein Modul:Typoskript Export beide Klasse und Typen
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;
}
So, jetzt, was ich tun kann, dass überall:
import FSTree = require('fs-tree-diff');
const tree = new FSTree({entries: []});
und es funktioniert! Aber ich möchte jetzt in der Lage sein, zu tun
import FSTree = require('fs-tree-diff');
const tree = new FSTree({entries: []});
let entry: FSTree.FSEntry;
...
Wenn ich versuche, export
hinzufügen vor jedem type
in meinem Modul Erklärung sagt, dass es am Ende auf export = ...
, dass es nicht mit anderen Exporte exportieren. Wie kann ich auf meine Dateien aus einer anderen Datei zugreifen?
Ja, das ist der Weg zu gehen. Viele DT-Typen sollten auf dieses Format umgestellt werden. :) – unional
BTW, warum sie nicht das Modul declare modue verwenden? – Vinz243
https://github.com/types/* ist nicht 'npm install @ types/*'. 'npm install @ types/*' kommt von https://github.com/definitelyped/definitelytyped – unional