Created
February 26, 2015 18:57
-
-
Save jonjaques/203f9d0a9937349fc3f8 to your computer and use it in GitHub Desktop.
TypeScript definitions for webpack require()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type definitions for Node.js v0.11.13 | |
// Project: http://nodejs.org/ | |
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped> | |
// Definitions: https://github.com/borisyankov/DefinitelyTyped | |
/************************************************ | |
* * | |
* Node.js v0.11.13 API * | |
* * | |
************************************************/ | |
/************************************************ | |
* * | |
* GLOBAL * | |
* * | |
************************************************/ | |
declare var process: NodeJS.Process; | |
declare var global: any; | |
declare var __filename: string; | |
declare var __dirname: string; | |
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; | |
declare function clearTimeout(timeoutId: NodeJS.Timer): void; | |
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; | |
declare function clearInterval(intervalId: NodeJS.Timer): void; | |
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; | |
declare function clearImmediate(immediateId: any): void; | |
declare var require: { | |
(id: string): any; | |
resolve(id: string): string; | |
cache: any; | |
extensions: any; | |
main: any; | |
}; | |
declare var module: { | |
exports: any; | |
require(id: string): any; | |
id: string; | |
filename: string; | |
loaded: boolean; | |
parent: any; | |
children: any[]; | |
}; | |
// Same as module.exports | |
declare var exports: any; | |
declare var SlowBuffer: { | |
new (str: string, encoding?: string): Buffer; | |
new (size: number): Buffer; | |
new (size: Uint8Array): Buffer; | |
new (array: any[]): Buffer; | |
prototype: Buffer; | |
isBuffer(obj: any): boolean; | |
byteLength(string: string, encoding?: string): number; | |
concat(list: Buffer[], totalLength?: number): Buffer; | |
}; | |
// Buffer class | |
interface Buffer extends NodeBuffer { } | |
declare var Buffer: { | |
new (str: string, encoding?: string): Buffer; | |
new (size: number): Buffer; | |
new (size: Uint8Array): Buffer; | |
new (array: any[]): Buffer; | |
prototype: Buffer; | |
isBuffer(obj: any): boolean; | |
byteLength(string: string, encoding?: string): number; | |
concat(list: Buffer[], totalLength?: number): Buffer; | |
}; | |
/************************************************ | |
* * | |
* GLOBAL INTERFACES * | |
* * | |
************************************************/ | |
declare module NodeJS { | |
export interface ErrnoException extends Error { | |
errno?: any; | |
code?: string; | |
path?: string; | |
syscall?: string; | |
} | |
export interface EventEmitter { | |
addListener(event: string, listener: Function): EventEmitter; | |
on(event: string, listener: Function): EventEmitter; | |
once(event: string, listener: Function): EventEmitter; | |
removeListener(event: string, listener: Function): EventEmitter; | |
removeAllListeners(event?: string): EventEmitter; | |
setMaxListeners(n: number): void; | |
listeners(event: string): Function[]; | |
emit(event: string, ...args: any[]): boolean; | |
} | |
export interface ReadableStream extends EventEmitter { | |
readable: boolean; | |
read(size?: number): any; | |
setEncoding(encoding: string): void; | |
pause(): void; | |
resume(): void; | |
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T; | |
unpipe<T extends WritableStream>(destination?: T): void; | |
unshift(chunk: string): void; | |
unshift(chunk: Buffer): void; | |
wrap(oldStream: ReadableStream): ReadableStream; | |
} | |
export interface WritableStream extends EventEmitter { | |
writable: boolean; | |
write(buffer: Buffer, cb?: Function): boolean; | |
write(str: string, cb?: Function): boolean; | |
write(str: string, encoding?: string, cb?: Function): boolean; | |
end(): void; | |
end(buffer: Buffer, cb?: Function): void; | |
end(str: string, cb?: Function): void; | |
end(str: string, encoding?: string, cb?: Function): void; | |
} | |
export interface ReadWriteStream extends ReadableStream, WritableStream { } | |
export interface Process extends EventEmitter { | |
stdout: WritableStream; | |
stderr: WritableStream; | |
stdin: ReadableStream; | |
argv: string[]; | |
execPath: string; | |
abort(): void; | |
chdir(directory: string): void; | |
cwd(): string; | |
env: any; | |
exit(code?: number): void; | |
getgid(): number; | |
setgid(id: number): void; | |
setgid(id: string): void; | |
getuid(): number; | |
setuid(id: number): void; | |
setuid(id: string): void; | |
version: string; | |
versions: { | |
http_parser: string; | |
node: string; | |
v8: string; | |
ares: string; | |
uv: string; | |
zlib: string; | |
openssl: string; | |
}; | |
config: { | |
target_defaults: { | |
cflags: any[]; | |
default_configuration: string; | |
defines: string[]; | |
include_dirs: string[]; | |
libraries: string[]; | |
}; | |
variables: { | |
clang: number; | |
host_arch: string; | |
node_install_npm: boolean; | |
node_install_waf: boolean; | |
node_prefix: string; | |
node_shared_openssl: boolean; | |
node_shared_v8: boolean; | |
node_shared_zlib: boolean; | |
node_use_dtrace: boolean; | |
node_use_etw: boolean; | |
node_use_openssl: boolean; | |
target_arch: string; | |
v8_no_strict_aliasing: number; | |
v8_use_snapshot: boolean; | |
visibility: string; | |
}; | |
}; | |
kill(pid: number, signal?: string): void; | |
pid: number; | |
title: string; | |
arch: string; | |
platform: string; | |
memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; | |
nextTick(callback: Function): void; | |
umask(mask?: number): number; | |
uptime(): number; | |
hrtime(time?: number[]): number[]; | |
// Worker | |
send? (message: any, sendHandle?: any): void; | |
} | |
export interface Timer { | |
ref(): void; | |
unref(): void; | |
} | |
} | |
/** | |
* @deprecated | |
*/ | |
interface NodeBuffer { | |
[index: number]: number; | |
write(string: string, offset?: number, length?: number, encoding?: string): number; | |
toString(encoding?: string, start?: number, end?: number): string; | |
toJSON(): any; | |
length: number; | |
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; | |
slice(start?: number, end?: number): Buffer; | |
readUInt8(offset: number, noAsset?: boolean): number; | |
readUInt16LE(offset: number, noAssert?: boolean): number; | |
readUInt16BE(offset: number, noAssert?: boolean): number; | |
readUInt32LE(offset: number, noAssert?: boolean): number; | |
readUInt32BE(offset: number, noAssert?: boolean): number; | |
readInt8(offset: number, noAssert?: boolean): number; | |
readInt16LE(offset: number, noAssert?: boolean): number; | |
readInt16BE(offset: number, noAssert?: boolean): number; | |
readInt32LE(offset: number, noAssert?: boolean): number; | |
readInt32BE(offset: number, noAssert?: boolean): number; | |
readFloatLE(offset: number, noAssert?: boolean): number; | |
readFloatBE(offset: number, noAssert?: boolean): number; | |
readDoubleLE(offset: number, noAssert?: boolean): number; | |
readDoubleBE(offset: number, noAssert?: boolean): number; | |
writeUInt8(value: number, offset: number, noAssert?: boolean): void; | |
writeUInt16LE(value: number, offset: number, noAssert?: boolean): void; | |
writeUInt16BE(value: number, offset: number, noAssert?: boolean): void; | |
writeUInt32LE(value: number, offset: number, noAssert?: boolean): void; | |
writeUInt32BE(value: number, offset: number, noAssert?: boolean): void; | |
writeInt8(value: number, offset: number, noAssert?: boolean): void; | |
writeInt16LE(value: number, offset: number, noAssert?: boolean): void; | |
writeInt16BE(value: number, offset: number, noAssert?: boolean): void; | |
writeInt32LE(value: number, offset: number, noAssert?: boolean): void; | |
writeInt32BE(value: number, offset: number, noAssert?: boolean): void; | |
writeFloatLE(value: number, offset: number, noAssert?: boolean): void; | |
writeFloatBE(value: number, offset: number, noAssert?: boolean): void; | |
writeDoubleLE(value: number, offset: number, noAssert?: boolean): void; | |
writeDoubleBE(value: number, offset: number, noAssert?: boolean): void; | |
fill(value: any, offset?: number, end?: number): void; | |
} | |
/************************************************ | |
* * | |
* MODULES * | |
* * | |
************************************************/ | |
declare module "buffer" { | |
export var INSPECT_MAX_BYTES: number; | |
} | |
declare module "querystring" { | |
export function stringify(obj: any, sep?: string, eq?: string): string; | |
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; | |
export function escape(str: string): string; | |
export function unescape(str: string): string; | |
} | |
declare module "events" { | |
export class EventEmitter implements NodeJS.EventEmitter { | |
static listenerCount(emitter: EventEmitter, event: string): number; | |
addListener(event: string, listener: Function): EventEmitter; | |
on(event: string, listener: Function): EventEmitter; | |
once(event: string, listener: Function): EventEmitter; | |
removeListener(event: string, listener: Function): EventEmitter; | |
removeAllListeners(event?: string): EventEmitter; | |
setMaxListeners(n: number): void; | |
listeners(event: string): Function[]; | |
emit(event: string, ...args: any[]): boolean; | |
} | |
} | |
declare module "os" { | |
export function tmpdir(): string; | |
export function hostname(): string; | |
export function type(): string; | |
export function platform(): string; | |
export function arch(): string; | |
export function release(): string; | |
export function uptime(): number; | |
export function loadavg(): number[]; | |
export function totalmem(): number; | |
export function freemem(): number; | |
export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[]; | |
export function networkInterfaces(): any; | |
export var EOL: string; | |
} | |
declare module "punycode" { | |
export function decode(string: string): string; | |
export function encode(string: string): string; | |
export function toUnicode(domain: string): string; | |
export function toASCII(domain: string): string; | |
export var ucs2: ucs2; | |
interface ucs2 { | |
decode(string: string): string; | |
encode(codePoints: number[]): string; | |
} | |
export var version: any; | |
} | |
declare module "readline" { | |
import events = require("events"); | |
import stream = require("stream"); | |
export interface ReadLine extends events.EventEmitter { | |
setPrompt(prompt: string, length: number): void; | |
prompt(preserveCursor?: boolean): void; | |
question(query: string, callback: Function): void; | |
pause(): void; | |
resume(): void; | |
close(): void; | |
write(data: any, key?: any): void; | |
} | |
export interface ReadLineOptions { | |
input: NodeJS.ReadableStream; | |
output: NodeJS.WritableStream; | |
completer?: Function; | |
terminal?: boolean; | |
} | |
export function createInterface(options: ReadLineOptions): ReadLine; | |
} | |
declare module "path" { | |
export function normalize(p: string): string; | |
export function join(...paths: any[]): string; | |
export function resolve(...pathSegments: any[]): string; | |
export function relative(from: string, to: string): string; | |
export function dirname(p: string): string; | |
export function basename(p: string, ext?: string): string; | |
export function extname(p: string): string; | |
export var sep: string; | |
} | |
declare module "string_decoder" { | |
export interface NodeStringDecoder { | |
write(buffer: Buffer): string; | |
detectIncompleteChar(buffer: Buffer): number; | |
} | |
export var StringDecoder: { | |
new (encoding: string): NodeStringDecoder; | |
}; | |
} | |
declare module "stream" { | |
import events = require("events"); | |
export interface Stream extends events.EventEmitter { | |
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T; | |
} | |
export interface ReadableOptions { | |
highWaterMark?: number; | |
encoding?: string; | |
objectMode?: boolean; | |
} | |
export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { | |
readable: boolean; | |
constructor(opts?: ReadableOptions); | |
_read(size: number): void; | |
read(size?: number): any; | |
setEncoding(encoding: string): void; | |
pause(): void; | |
resume(): void; | |
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T; | |
unpipe<T extends NodeJS.WritableStream>(destination?: T): void; | |
unshift(chunk: string): void; | |
unshift(chunk: Buffer): void; | |
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; | |
push(chunk: any, encoding?: string): boolean; | |
} | |
export interface WritableOptions { | |
highWaterMark?: number; | |
decodeStrings?: boolean; | |
} | |
export class Writable extends events.EventEmitter implements NodeJS.WritableStream { | |
writable: boolean; | |
constructor(opts?: WritableOptions); | |
_write(data: Buffer, encoding: string, callback: Function): void; | |
_write(data: string, encoding: string, callback: Function): void; | |
write(buffer: Buffer, cb?: Function): boolean; | |
write(str: string, cb?: Function): boolean; | |
write(str: string, encoding?: string, cb?: Function): boolean; | |
end(): void; | |
end(buffer: Buffer, cb?: Function): void; | |
end(str: string, cb?: Function): void; | |
end(str: string, encoding?: string, cb?: Function): void; | |
} | |
export interface DuplexOptions extends ReadableOptions, WritableOptions { | |
allowHalfOpen?: boolean; | |
} | |
// Note: Duplex extends both Readable and Writable. | |
export class Duplex extends Readable implements NodeJS.ReadWriteStream { | |
writable: boolean; | |
constructor(opts?: DuplexOptions); | |
_write(data: Buffer, encoding: string, callback: Function): void; | |
_write(data: string, encoding: string, callback: Function): void; | |
write(buffer: Buffer, cb?: Function): boolean; | |
write(str: string, cb?: Function): boolean; | |
write(str: string, encoding?: string, cb?: Function): boolean; | |
end(): void; | |
end(buffer: Buffer, cb?: Function): void; | |
end(str: string, cb?: Function): void; | |
end(str: string, encoding?: string, cb?: Function): void; | |
} | |
export interface TransformOptions extends ReadableOptions, WritableOptions { } | |
// Note: Transform lacks the _read and _write methods of Readable/Writable. | |
export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { | |
readable: boolean; | |
writable: boolean; | |
constructor(opts?: TransformOptions); | |
_transform(chunk: Buffer, encoding: string, callback: Function): void; | |
_transform(chunk: string, encoding: string, callback: Function): void; | |
_flush(callback: Function): void; | |
read(size?: number): any; | |
setEncoding(encoding: string): void; | |
pause(): void; | |
resume(): void; | |
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T; | |
unpipe<T extends NodeJS.WritableStream>(destination?: T): void; | |
unshift(chunk: string): void; | |
unshift(chunk: Buffer): void; | |
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; | |
push(chunk: any, encoding?: string): boolean; | |
write(buffer: Buffer, cb?: Function): boolean; | |
write(str: string, cb?: Function): boolean; | |
write(str: string, encoding?: string, cb?: Function): boolean; | |
end(): void; | |
end(buffer: Buffer, cb?: Function): void; | |
end(str: string, cb?: Function): void; | |
end(str: string, encoding?: string, cb?: Function): void; | |
} | |
export class PassThrough extends Transform { } | |
} | |
declare module "util" { | |
export interface InspectOptions { | |
showHidden?: boolean; | |
depth?: number; | |
colors?: boolean; | |
customInspect?: boolean; | |
} | |
export function format(format: any, ...param: any[]): string; | |
export function deprecate(fn: Function, msg: string): Function; | |
export function debuglog(set: string): Function; | |
export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; | |
export function inspect(object: any, options: InspectOptions): string; | |
export function isArray(object: any): boolean; | |
export function isBoolean(arg: any): boolean; | |
export function isNull(arg: any): boolean; | |
export function isNullOrUndefined(arg: any): boolean; | |
export function isNumber(arg: any): boolean; | |
export function isString(arg: any): boolean; | |
export function isSymbol(arg: any): boolean; | |
export function isUndefined(arg: any): boolean; | |
export function isRegExp(arg: any): boolean; | |
export function isObject(arg: any): boolean; | |
export function isDate(arg: any): boolean; | |
export function isError(arg: any): boolean; | |
export function isFunction(arg: any): boolean; | |
export function isPrimitive(arg: any): boolean; | |
export function isBuffer(arg: any): boolean; | |
export function log(...arg: any[]): void | |
export function inherits(constructor: any, superConstructor: any): void; | |
export function p(...arg: any[]): void; | |
export function exec(...arg: any[]): void; | |
export function print(...arg: any[]): void; | |
export function puts(...arg: any[]): void; | |
export function debug(string: string): void; | |
export function error(...arg: any[]): void; | |
} | |
declare module "assert" { | |
function internal(value: any, message?: string): void; | |
module internal { | |
export class AssertionError implements Error { | |
name: string; | |
message: string; | |
actual: any; | |
expected: any; | |
operator: string; | |
generatedMessage: boolean; | |
constructor(options?: { | |
message?: string; actual?: any; expected?: any; | |
operator?: string; stackStartFunction?: Function | |
}); | |
} | |
export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; | |
export function ok(value: any, message?: string): void; | |
export function equal(actual: any, expected: any, message?: string): void; | |
export function notEqual(actual: any, expected: any, message?: string): void; | |
export function deepEqual(actual: any, expected: any, message?: string): void; | |
export function notDeepEqual(acutal: any, expected: any, message?: string): void; | |
export function strictEqual(actual: any, expected: any, message?: string): void; | |
export function notStrictEqual(actual: any, expected: any, message?: string): void; | |
export var throws: { | |
(block: Function, message?: string): void; | |
(block: Function, error: Function, message?: string): void; | |
(block: Function, error: RegExp, message?: string): void; | |
(block: Function, error: (err: any) => boolean, message?: string): void; | |
}; | |
export var doesNotThrow: { | |
(block: Function, message?: string): void; | |
(block: Function, error: Function, message?: string): void; | |
(block: Function, error: RegExp, message?: string): void; | |
(block: Function, error: (err: any) => boolean, message?: string): void; | |
}; | |
export function ifError(value: any): void; | |
} | |
export = internal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment