Set type of symlink parameter 'type' to a union

This commit is contained in:
khai96_
2018-05-24 00:41:03 +07:00
parent e58e32cc7a
commit 80987f1428
4 changed files with 17 additions and 9 deletions
+5 -3
View File
@@ -10,7 +10,8 @@
/// <reference types="node" />
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<void>;
export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function stat(path: string | Buffer): Promise<Stats>;
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<void>;
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<void>;
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;
+4 -2
View File
@@ -3461,7 +3461,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.
@@ -3480,6 +3480,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<void>;
export type Type = "dir" | "file" | "junction";
}
/**
@@ -3489,7 +3491,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.
+4 -2
View File
@@ -3368,7 +3368,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.
@@ -3387,6 +3387,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<void>;
export type Type = "dir" | "file" | "junction";
}
/**
@@ -3396,7 +3398,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.
+4 -2
View File
@@ -3450,7 +3450,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.
@@ -3469,6 +3469,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<void>;
export type Type = "dir" | "file" | "junction";
}
/**
@@ -3478,7 +3480,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.