From cf0ccd4511208373e6729bc64ce54ddf07e84830 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 21 Apr 2018 14:26:41 -0700 Subject: [PATCH 1/2] 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; From 526ca393cb2532ff562d9e8c48ae6c10ef59858f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 21 Apr 2018 15:06:59 -0700 Subject: [PATCH 2/2] Fix lint nits. --- types/temp/index.d.ts | 26 +++++++++++++------------- types/temp/tslint.json | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/types/temp/index.d.ts b/types/temp/index.d.ts index eaf9adde66..25a76ec47e 100644 --- a/types/temp/index.d.ts +++ b/types/temp/index.d.ts @@ -8,41 +8,41 @@ import * as fs from "fs"; declare namespace temp { - export interface OpenFile { + interface OpenFile { path: string; fd: number; } - export interface Stats { + interface Stats { files: number; dirs: number; } - export interface AffixOptions { + interface AffixOptions { prefix?: string; suffix?: string; dir?: string; } - export let dir: string; + let dir: string; - export function track(value?: boolean): typeof temp; + function track(value?: boolean): typeof temp; - export function mkdir(affixes?: string | AffixOptions, callback?: (err: any, dirPath: string) => void): void; + function mkdir(affixes?: string | AffixOptions, callback?: (err: any, dirPath: string) => void): void; - export function mkdirSync(affixes?: string | AffixOptions): string; + function mkdirSync(affixes?: string | AffixOptions): string; - export function open(affixes?: string | AffixOptions, callback?: (err: any, result: OpenFile) => void): void; + function open(affixes?: string | AffixOptions, callback?: (err: any, result: OpenFile) => void): void; - export function openSync(affixes?: string | AffixOptions): OpenFile; + function openSync(affixes?: string | AffixOptions): OpenFile; - export function path(affixes?: string | AffixOptions, defaultPrefix?: string): string; + function path(affixes?: string | AffixOptions, defaultPrefix?: string): string; - export function cleanup(callback?: (result: boolean | Stats) => void): void; + function cleanup(callback?: (result: boolean | Stats) => void): void; - export function cleanupSync(): boolean | Stats; + function cleanupSync(): boolean | Stats; - export function createWriteStream(affixes?: string | AffixOptions): fs.WriteStream; + function createWriteStream(affixes?: string | AffixOptions): fs.WriteStream; } export = temp; diff --git a/types/temp/tslint.json b/types/temp/tslint.json index 495d29983d..adaee1b55f 100644 --- a/types/temp/tslint.json +++ b/types/temp/tslint.json @@ -1,5 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { + "export-just-namespace": false } }