Skip to content

Instantly share code, notes, and snippets.

@joeriks
Created March 30, 2013 13:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joeriks/5276607 to your computer and use it in GitHub Desktop.
Typescript definition for TSC's own IO.d.ts
interface IResolvedFile {
content: string;
path: string;
}
interface IFileWatcher {
close(): void;
}
interface IIO {
readFile(path: string): string;
writeFile(path: string, contents: string): void;
createFile(path: string, useUTF8?: bool): ITextWriter;
deleteFile(path: string): void;
dir(path: string, re?: RegExp, options?: {
recursive?: bool;
}): string[];
fileExists(path: string): bool;
directoryExists(path: string): bool;
createDirectory(path: string): void;
resolvePath(path: string): string;
dirName(path: string): string;
findFile(rootPath: string, partialFilePath: string): IResolvedFile;
print(str: string): void;
printLine(str: string): void;
arguments: string[];
stderr: ITextWriter;
stdout: ITextWriter;
watchFile(filename: string, callback: (string: any) => void): IFileWatcher;
run(source: string, filename: string): void;
getExecutingFilePath(): string;
quit(exitCode?: number);
}
module IOUtils {
function createFileAndFolderStructure(ioHost: IIO, fileName: string, useUTF8?: bool): ITextWriter;
function throwIOError(message: string, error: Error): void;
class BufferedTextWriter implements ITextWriter {
public writer: {
Write: (str: string) => void;
Close: () => void;
};
public capacity;
public buffer: string;
constructor(writer: {
Write: (str: string) => void;
Close: () => void;
}, capacity?: number);
public Write(str): void;
public WriteLine(str): void;
public Close(): void;
}
}
class Enumerator {
public atEnd(): bool;
public moveNext();
public item(): any;
constructor(o: any);
}
module process {
var argv: string[];
var platform: string;
function on(event: string, handler: (any: any) => void): void;
module stdout {
function write(str: string);
}
module stderr {
function write(str: string);
}
module mainModule {
var filename: string;
}
function exit(exitCode?: number);
}
var IO: IIO;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment