diff --git a/types/node/index.d.ts b/types/node/index.d.ts index fbd0a4c211..d474a1045a 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -4580,7 +4580,6 @@ declare module "path" { */ name: string; } - export interface FormatInputPathObject { /** * The root of the path such as '/' or 'c:\' @@ -4693,7 +4692,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } export module win32 { @@ -4708,7 +4707,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } } diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 1ed9332e94..e0c2b22b10 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1759,6 +1759,46 @@ namespace path_tests { }); // returns // '/home/user/dir/file.txt' + + path.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + root: "/", + dir: "/home/user/dir", + base: "file.txt", + ext: ".txt", + name: "file" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.win32.format({ + root: "C:\\", + dir: "C:\\home\\user\\dir", + ext: ".txt", + name: "file" + }); + // returns + // 'C:\home\user\dir\file.txt' + + path.win32.format({ + dir: "C:\\home\\user\\dir", + base: "file.txt" + }); + // returns + // 'C:\home\user\dir\file.txt' } //////////////////////////////////////////////////// diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index eefbf46bef..259259afd0 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -1993,6 +1993,28 @@ declare module "path" { */ name: string; } + export interface FormatInputPathObject { + /** + * The root of the path such as '/' or 'c:\' + */ + root?: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir?: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base?: string; + /** + * The file extension (if any) such as '.html' + */ + ext?: string; + /** + * The file name without extension (if any) such as 'index' + */ + name?: string; + } /** * Normalize a string path, reducing '..' and '.' parts. @@ -2076,7 +2098,7 @@ declare module "path" { * * @param pathString path to evaluate. */ - export function format(pathObject: ParsedPath): string; + export function format(pathObject: FormatInputPathObject): string; export module posix { export function normalize(p: string): string; @@ -2090,7 +2112,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } export module win32 { @@ -2105,7 +2127,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } } diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 431dfb0520..2bb28ce779 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -772,6 +772,46 @@ namespace path_tests { }); // returns // '/home/user/dir/file.txt' + + path.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + root: "/", + dir: "/home/user/dir", + base: "file.txt", + ext: ".txt", + name: "file" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.win32.format({ + root: "C:\\", + dir: "C:\\home\\user\\dir", + ext: ".txt", + name: "file" + }); + // returns + // 'C:\home\user\dir\file.txt' + + path.win32.format({ + dir: "C:\\home\\user\\dir", + base: "file.txt" + }); + // returns + // 'C:\home\user\dir\file.txt' } //////////////////////////////////////////////////// diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 1a697551a4..0c84770e93 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -2875,6 +2875,28 @@ declare module "path" { */ name: string; } + export interface FormatInputPathObject { + /** + * The root of the path such as '/' or 'c:\' + */ + root?: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir?: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base?: string; + /** + * The file extension (if any) such as '.html' + */ + ext?: string; + /** + * The file name without extension (if any) such as 'index' + */ + name?: string; + } /** * Normalize a string path, reducing '..' and '.' parts. @@ -2951,7 +2973,7 @@ declare module "path" { * * @param pathString path to evaluate. */ - export function format(pathObject: ParsedPath): string; + export function format(pathObject: FormatInputPathObject): string; export module posix { export function normalize(p: string): string; @@ -2965,7 +2987,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } export module win32 { @@ -2980,7 +3002,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } } diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 171b92ba1a..34a62bf88d 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -1282,6 +1282,47 @@ namespace path_tests { }); // returns // '/home/user/dir/file.txt' + + + path.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + root: "/", + dir: "/home/user/dir", + base: "file.txt", + ext: ".txt", + name: "file" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.win32.format({ + root: "C:\\", + dir: "C:\\home\\user\\dir", + ext: ".txt", + name: "file" + }); + // returns + // 'C:\home\user\dir\file.txt' + + path.win32.format({ + dir: "C:\\home\\user\\dir", + base: "file.txt" + }); + // returns + // 'C:\home\user\dir\file.txt' } //////////////////////////////////////////////////// diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index 25c120ad3c..f0766a2da2 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -3005,6 +3005,28 @@ declare module "path" { */ name: string; } + export interface FormatInputPathObject { + /** + * The root of the path such as '/' or 'c:\' + */ + root?: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir?: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base?: string; + /** + * The file extension (if any) such as '.html' + */ + ext?: string; + /** + * The file name without extension (if any) such as 'index' + */ + name?: string; + } /** * Normalize a string path, reducing '..' and '.' parts. @@ -3081,7 +3103,7 @@ declare module "path" { * * @param pathString path to evaluate. */ - export function format(pathObject: ParsedPath): string; + export function format(pathObject: FormatInputPathObject): string; export module posix { export function normalize(p: string): string; @@ -3095,7 +3117,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } export module win32 { @@ -3110,7 +3132,7 @@ declare module "path" { export var sep: string; export var delimiter: string; export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; + export function format(pP: FormatInputPathObject): string; } } diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index f0878cc6fc..a2f25db8ec 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -1379,6 +1379,46 @@ namespace path_tests { }); // returns // '/home/user/dir/file.txt' + + path.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + root: "/", + dir: "/home/user/dir", + base: "file.txt", + ext: ".txt", + name: "file" + }); + // returns + // '/home/user/dir/file.txt' + + path.posix.format({ + dir: "/home/user/dir", + base: "file.txt" + }); + // returns + // '/home/user/dir/file.txt' + + path.win32.format({ + root: "C:\\", + dir: "C:\\home\\user\\dir", + ext: ".txt", + name: "file" + }); + // returns + // 'C:\home\user\dir\file.txt' + + path.win32.format({ + dir: "C:\\home\\user\\dir", + base: "file.txt" + }); + // returns + // 'C:\home\user\dir\file.txt' } ////////////////////////////////////////////////////