diff --git a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts index bdff193912..9e076ff8eb 100644 --- a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts +++ b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts @@ -18,7 +18,7 @@ let buffer: Buffer; declare const modeNum: number; declare const modeStr: string; declare const encoding: string; -declare const type: string; +declare const symlinkType: "file" | "dir" | "junction"; declare const flags: string; declare const srcpath: string; declare const dstpath: string; @@ -117,8 +117,8 @@ stats = fs.lstatSync(path); stats = fs.fstatSync(fd); fs.link(srcpath, dstpath, errorCallback); fs.linkSync(srcpath, dstpath); -fs.symlink(srcpath, dstpath, type, errorCallback); -fs.symlinkSync(srcpath, dstpath, type); +fs.symlink(srcpath, dstpath, symlinkType, errorCallback); +fs.symlinkSync(srcpath, dstpath, symlinkType); fs.readlink(path, (err: Error, linkString: string) => { }); fs.realpath(path, (err: Error, resolvedPath: string) => { diff --git a/types/fs-extra-promise-es6/index.d.ts b/types/fs-extra-promise-es6/index.d.ts index 2b7dacd108..125fa51679 100644 --- a/types/fs-extra-promise-es6/index.d.ts +++ b/types/fs-extra-promise-es6/index.d.ts @@ -90,7 +90,7 @@ export function fstatSync(fd: number): Stats; export function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; export function linkSync(srcpath: string, dstpath: string): void; export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; -export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; +export function symlinkSync(srcpath: string, dstpath: string, type?: fs.symlink.Type): void; export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; @@ -189,7 +189,7 @@ export function statAsync(path: string): Promise; export function lstatAsync(path: string): Promise; export function fstatAsync(fd: number): Promise; export function linkAsync(srcpath: string, dstpath: string): Promise; -export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: fs.symlink.Type): Promise; export function readlinkAsync(path: string): Promise; export function realpathAsync(path: string, cache?: string): Promise; export function unlinkAsync(path: string): Promise; diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index 61549a55ad..441e62b884 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -20,7 +20,7 @@ let buffer: Buffer; declare const modeNum: number; declare const modeStr: string; declare const encoding: string; -declare const type: string; +declare const symlinkType: "file" | "dir" | "junction"; declare const flags: string; declare const srcpath: string; declare const dstpath: string; @@ -117,8 +117,8 @@ stats = fs.lstatSync(path); stats = fs.fstatSync(fd); fs.link(srcpath, dstpath, errorCallback); fs.linkSync(srcpath, dstpath); -fs.symlink(srcpath, dstpath, type, errorCallback); -fs.symlinkSync(srcpath, dstpath, type); +fs.symlink(srcpath, dstpath, symlinkType, errorCallback); +fs.symlinkSync(srcpath, dstpath, symlinkType); fs.readlink(path, (err: Error, linkString: string) => { }); fs.realpath(path, (err: Error, resolvedPath: string) => { diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index b4ac5be133..a7222b9d5d 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -7,9 +7,10 @@ /// import * as stream from 'stream'; -import { Stats } from 'fs'; +import * as fs from 'fs'; import * as Promise from 'bluebird'; import { CopyFilter, CopyOptions, ReadOptions, WriteOptions, MoveOptions } from 'fs-extra'; +import Stats = fs.Stats; export * from 'fs-extra'; @@ -53,7 +54,7 @@ export function statAsync(path: string): Promise; export function lstatAsync(path: string): Promise; export function fstatAsync(fd: number): Promise; export function linkAsync(srcpath: string, dstpath: string): Promise; -export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: fs.symlink.Type): Promise; export function readlinkAsync(path: string): Promise; export function realpathAsync(path: string, cache?: { [path: string]: string }): Promise; export function unlinkAsync(path: string): Promise; diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index adf236955b..153b285ae1 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -10,7 +10,8 @@ /// -import { Stats } from "fs"; +import * as fs from "fs"; +import Stats = fs.Stats; export * from "fs"; @@ -206,8 +207,9 @@ export function rmdir(path: string | Buffer): Promise; export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; export function stat(path: string | Buffer): Promise; -export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err: NodeJS.ErrnoException) => void): void; -export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise; +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: fs.symlink.Type | undefined, callback: (err: NodeJS.ErrnoException) => void): void; +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: fs.symlink.Type): Promise; export function truncate(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; export function truncate(path: string | Buffer, len: number, callback: (err: NodeJS.ErrnoException) => void): void; diff --git a/types/node/index.d.ts b/types/node/index.d.ts index f7519cb076..070c668e11 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -3470,7 +3470,7 @@ declare module "fs" { * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ - export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; + export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; /** * Asynchronous symlink(2) - Create a new symbolic link to an existing file. @@ -3489,6 +3489,8 @@ declare module "fs" { * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise; + + export type Type = "dir" | "file" | "junction"; } /** @@ -3498,7 +3500,7 @@ declare module "fs" { * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ - export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void; + export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; /** * Asynchronous readlink(2) - read value of a symbolic link. diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index 77d756300f..bc4fa2d749 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -3371,7 +3371,7 @@ declare module "fs" { * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ - export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; + export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; /** * Asynchronous symlink(2) - Create a new symbolic link to an existing file. @@ -3390,6 +3390,8 @@ declare module "fs" { * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise; + + export type Type = "dir" | "file" | "junction"; } /** @@ -3399,7 +3401,7 @@ declare module "fs" { * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ - export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void; + export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; /** * Asynchronous readlink(2) - read value of a symbolic link. diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index e8b48fe0ad..1c9e01cc01 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -3453,7 +3453,7 @@ declare module "fs" { * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ - export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; + export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; /** * Asynchronous symlink(2) - Create a new symbolic link to an existing file. @@ -3472,6 +3472,8 @@ declare module "fs" { * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise; + + export type Type = "dir" | "file" | "junction"; } /** @@ -3481,7 +3483,7 @@ declare module "fs" { * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. */ - export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void; + export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; /** * Asynchronous readlink(2) - read value of a symbolic link.