mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Node: path.format input properties are optional (#21003)
* Node: `path.format` input properties are optional If `base` does not exist, `name` and `ext` will be used to compute it. http://devdocs.io/node/path#path_path_format_pathobject * Node: `FormatInputPathObject`: all properties are optional * Node: add myself as author * Avoid usage of `Partial`
This commit is contained in:
26
types/node/index.d.ts
vendored
26
types/node/index.d.ts
vendored
@@ -13,6 +13,7 @@
|
||||
// Deividas Bakanas <https://github.com/DeividasBakanas>
|
||||
// Kelvin Jin <https://github.com/kjin>
|
||||
// Alvis HT Tang <https://github.com/alvis>
|
||||
// Oliver Joseph Ash <https://github.com/OliverJAsh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/************************************************
|
||||
@@ -4426,6 +4427,29 @@ 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.
|
||||
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
||||
@@ -4504,7 +4528,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;
|
||||
|
||||
@@ -1651,6 +1651,15 @@ namespace path_tests {
|
||||
});
|
||||
// returns
|
||||
// '/home/user/dir/file.txt'
|
||||
|
||||
path.format({
|
||||
root: "/",
|
||||
dir: "/home/user/dir",
|
||||
ext: ".txt",
|
||||
name: "file"
|
||||
});
|
||||
// returns
|
||||
// '/home/user/dir/file.txt'
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user