From cf0ccd4511208373e6729bc64ce54ddf07e84830 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 21 Apr 2018 14:26:41 -0700 Subject: [PATCH] Use namespace with 'export =' to model self-referential chaining API in 'temp'. --- types/temp/index.d.ts | 71 ++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/types/temp/index.d.ts b/types/temp/index.d.ts index 0a452a221b..eaf9adde66 100644 --- a/types/temp/index.d.ts +++ b/types/temp/index.d.ts @@ -5,41 +5,44 @@ /// -import * as temp from "."; import * as fs from "fs"; -export interface OpenFile { - path: string; - fd: number; +declare namespace temp { + export interface OpenFile { + path: string; + fd: number; + } + + export interface Stats { + files: number; + dirs: number; + } + + export interface AffixOptions { + prefix?: string; + suffix?: string; + dir?: string; + } + + export let dir: string; + + export function track(value?: boolean): typeof temp; + + export function mkdir(affixes?: string | AffixOptions, callback?: (err: any, dirPath: string) => void): void; + + export function mkdirSync(affixes?: string | AffixOptions): string; + + export function open(affixes?: string | AffixOptions, callback?: (err: any, result: OpenFile) => void): void; + + export function openSync(affixes?: string | AffixOptions): OpenFile; + + export function path(affixes?: string | AffixOptions, defaultPrefix?: string): string; + + export function cleanup(callback?: (result: boolean | Stats) => void): void; + + export function cleanupSync(): boolean | Stats; + + export function createWriteStream(affixes?: string | AffixOptions): fs.WriteStream; } -export interface Stats { - files: number; - dirs: number; -} - -export interface AffixOptions { - prefix?: string; - suffix?: string; - dir?: string; -} - -export let dir: string; - -export function track(value?: boolean): typeof temp; - -export function mkdir(affixes?: string | AffixOptions, callback?: (err: any, dirPath: string) => void): void; - -export function mkdirSync(affixes?: string | AffixOptions): string; - -export function open(affixes?: string | AffixOptions, callback?: (err: any, result: OpenFile) => void): void; - -export function openSync(affixes?: string | AffixOptions): OpenFile; - -export function path(affixes?: string | AffixOptions, defaultPrefix?: string): string; - -export function cleanup(callback?: (result: boolean | Stats) => void): void; - -export function cleanupSync(): boolean | Stats; - -export function createWriteStream(affixes?: string | AffixOptions): fs.WriteStream; +export = temp;