From 9d9387ceae23847e77b8c220c4e9a6e36024a7da Mon Sep 17 00:00:00 2001 From: Dmitry Demeshkin Date: Tue, 7 Nov 2017 16:10:21 +0800 Subject: [PATCH 01/12] Codemirror: text parameter should be an array in EditorChangeCancellable.update method --- types/codemirror/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index cfcbd9d5b3..126eafe013 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -692,7 +692,7 @@ declare namespace CodeMirror { interface EditorChangeCancellable extends CodeMirror.EditorChange { /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */ - update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string): void; + update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void; cancel(): void; } From d8765f8b5d45c543d169023f94e12ec00424f284 Mon Sep 17 00:00:00 2001 From: King Wang Date: Fri, 10 Nov 2017 15:37:20 +0800 Subject: [PATCH 02/12] Update index.d.ts SetOption value should be any (maybe boolean, number ...) --- types/showdown/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index 62cecfda30..cb3b9ae088 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -300,7 +300,7 @@ declare namespace Showdown { * @param optionKey * @param string */ - setOption(optionKey: string, value: string): void; + setOption(optionKey: string, value: any): void; /** * Get the option of this Converter instance. From 19950de901f57adcc43ab69fe11b90a5cfe80457 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Sat, 11 Nov 2017 10:23:25 -0800 Subject: [PATCH 03/12] Remove overloads for more accurate types; improve ShellString ShellString still isn't used, though. --- types/shelljs/index.d.ts | 193 +++++++++------------------------------ 1 file changed, 45 insertions(+), 148 deletions(-) diff --git a/types/shelljs/index.d.ts b/types/shelljs/index.d.ts index f3e386303c..ef292c1584 100644 --- a/types/shelljs/index.d.ts +++ b/types/shelljs/index.d.ts @@ -26,7 +26,7 @@ export function pwd(): string; * @param ...paths Paths to search. * @return An array of files in the given path(s). */ -export function ls(...paths: string[]): string[]; +export function ls(...paths: (string | string[])[]): string[]; /** * Returns array of files in the given path, or in current directory if no path provided. @@ -34,50 +34,21 @@ export function ls(...paths: string[]): string[]; * @param ...paths Paths to search. * @return An array of files in the given path(s). */ -export function ls(options: string, ...paths: string[]): string[]; - -/** - * Returns array of files in the given path, or in current directory if no path provided. - * @param paths Paths to search. - * @return An array of files in the given path(s). - */ -export function ls(paths: string[]): string[]; - -/** - * Returns array of files in the given path, or in current directory if no path provided. - * @param options Available options: -R (recursive), -A (all files, include files beginning with ., except for . and ..) - * @param paths Paths to search. - * @return An array of files in the given path(s). - */ -export function ls(options: string, paths: string[]): string[]; +export function ls(options: string, ...paths: (string | string[])[]): string[]; /** * Returns array of all files (however deep) in the given paths. * @param ...path The path(s) to search. * @return An array of all files (however deep) in the given path(s). */ -export function find(...path: string[]): string[]; - -/** - * Returns array of all files (however deep) in the given paths. - * @param path The path(s) to search. - * @return An array of all files (however deep) in the given path(s). - */ -export function find(path: string[]): string[]; +export function find(...path: (string | string[])[]): string[]; /** * Copies files. The wildcard * is accepted. * @param source The source. * @param dest The destination. */ -export function cp(source: string, dest: string): void; - -/** - * Copies files. The wildcard * is accepted. - * @param source The source. - * @param dest The destination. - */ -export function cp(source: string[], dest: string): void; +export function cp(source: string | string[], dest: string): void; /** * Copies files. The wildcard * is accepted. @@ -85,81 +56,40 @@ export function cp(source: string[], dest: string): void; * @param source The source. * @param dest The destination. */ -export function cp(options: string, source: string, dest: string): void; - -/** - * Copies files. The wildcard * is accepted. - * @param options Available options: -f (force), -r, -R (recursive) - * @param source The source. - * @param dest The destination. - */ -export function cp(options: string, source: string[], dest: string): void; +export function cp(options: string, source: string | string[], dest: string): void; /** * Removes files. The wildcard * is accepted. * @param ...files Files to remove. */ -export function rm(...files: string[]): void; - -/** - * Removes files. The wildcard * is accepted. - * @param files Files to remove. - */ -export function rm(files: string[]): void; +export function rm(...files: (string | string[])[]): void; /** * Removes files. The wildcard * is accepted. * @param options Available options: -f (force), -r, -R (recursive) * @param ...files Files to remove. */ -export function rm(options: string, ...files: string[]): void; - -/** - * Removes files. The wildcard * is accepted. - * @param options Available options: -f (force), -r, -R (recursive) - * @param ...files Files to remove. - */ -export function rm(options: string, files: string[]): void; +export function rm(options: string, ...files: (string | string[])[]): void; /** * Moves files. The wildcard * is accepted. * @param source The source. * @param dest The destination. */ -export function mv(source: string, dest: string): void; - -/** - * Moves files. The wildcard * is accepted. - * @param source The source. - * @param dest The destination. - */ -export function mv(source: string[], dest: string): void; +export function mv(source: string | string[], dest: string): void; /** * Creates directories. * @param ...dir Directories to create. */ -export function mkdir(...dir: string[]): void; - -/** - * Creates directories. - * @param dir Directories to create. - */ -export function mkdir(dir: string[]): void; +export function mkdir(...dir: (string | string[])[]): void; /** * Creates directories. * @param options Available options: p (full paths, will create intermediate dirs if necessary) * @param ...dir The directories to create. */ -export function mkdir(options: string, ...dir: string[]): void; - -/** - * Creates directories. - * @param options Available options: p (full paths, will create intermediate dirs if necessary) - * @param dir The directories to create. - */ -export function mkdir(options: string, dir: string[]): void; +export function mkdir(options: string, ...dir: (string | string[])[]): void; /** * Evaluates expression using the available primaries and returns corresponding value. @@ -174,29 +104,7 @@ export function test(option: string, path: string): boolean; * @param ...files Files to use. * @return A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). */ -export function cat(...files: string[]): string; - -/** - * Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). Wildcard * accepted. - * @param files Files to use. - * @return A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). - */ -export function cat(files: string[]): string; - -// Does not work yet. -export interface String { - /** - * Analogous to the redirection operator > in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc). Like Unix redirections, to() will overwrite any existing file! - * @param file The file to use. - */ - to(file: string): void; - - /** - * Analogous to the redirect-and-append operator >> in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc). - * @param file The file to append to. - */ - toEnd(file: string): void; -} +export function cat(...files: (string | string[])[]): string; /** * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. @@ -205,16 +113,7 @@ export interface String { * @param file The file to process. * @return The new string after replacement. */ -export function sed(searchRegex: RegExp, replacement: string, file: string): string; - -/** - * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. - * @param searchRegex The regular expression to use for search. - * @param replacement The replacement. - * @param file The file to process. - * @return The new string after replacement. - */ -export function sed(searchRegex: string, replacement: string, file: string): string; +export function sed(searchRegex: string | RegExp, replacement: string, file: string): string; /** * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. @@ -224,17 +123,7 @@ export function sed(searchRegex: string, replacement: string, file: string): str * @param file The file to process. * @return The new string after replacement. */ -export function sed(options: string, searchRegex: RegExp, replacement: string, file: string): string; - -/** - * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. - * @param options Available options: -i (Replace contents of 'file' in-place. Note that no backups will be created!) - * @param searchRegex The regular expression to use for search. - * @param replacement The replacement. - * @param file The file to process. - * @return The new string after replacement. - */ -export function sed(options: string, searchRegex: string, replacement: string, file: string): string; +export function sed(options: string, searchRegex: string | RegExp, replacement: string, file: string): string; /** * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. @@ -242,15 +131,7 @@ export function sed(options: string, searchRegex: string, replacement: string, f * @param ...files The files to process. * @return Returns a string containing all lines of the file that match the given regex_filter. */ -export function grep(regex_filter: RegExp, ...files: string[]): string; - -/** - * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. - * @param regex_filter The regular expression to use. - * @param ...files The files to process. - * @return Returns a string containing all lines of the file that match the given regex_filter. - */ -export function grep(regex_filter: RegExp, files: string[]): string; +export function grep(regex_filter: string | RegExp, ...files: (string | string[])[]): string; /** * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. @@ -259,16 +140,7 @@ export function grep(regex_filter: RegExp, files: string[]): string; * @param ...files The files to process. * @return Returns a string containing all lines of the file that match the given regex_filter. */ -export function grep(options: string, regex_filter: string, ...files: string[]): string; - -/** - * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. - * @param options Available options: -v (Inverse the sense of the regex and print the lines not matching the criteria.) - * @param regex_filter The regular expression to use. - * @param files The files to process. - * @return Returns a string containing all lines of the file that match the given regex_filter. - */ -export function grep(options: string, regex_filter: string, files: string[]): string; +export function grep(options: string, regex_filter: string | RegExp, ...files: (string | string[])[]): string; /** * Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions. @@ -474,6 +346,33 @@ export interface ExecOutputReturnValue { stderr: string; } +export interface ShellReturnValue extends ExecOutputReturnValue { + /** + * Analogous to the redirection operator > in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc). Like Unix redirections, to() will overwrite any existing file! + * @param file The file to use. + */ + to(file: string): void; + + /** + * Analogous to the redirect-and-append operator >> in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc). + * @param file The file to append to. + */ + toEnd(file: string): void; + + cat(...files: string[]): string; + exec(callback: ExecCallback): child.ChildProcess; + exec(): ExecOutputReturnValue; + grep(...files: (string | string[])[]): string; + sed(replacement: string, file: string): string; +} + +export interface ShellString extends String, ShellReturnValue { +} + +export interface ShellArray extends Array, ShellReturnValue { +} + + /** * Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions: * - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask. @@ -511,17 +410,15 @@ export type TouchOptionsLiteral = "-a" | "-c" | "-m" | "-d" | "-r"; /** * Update the access and modification times of each FILE to the current time. A FILE argument that does not exist is created empty, unless -c is supplied */ -export interface touchOptionsArray { +export interface TouchOptionsArray { '-d'?: string; '-r'?: string; } export function touch(...files: string[]): void; export function touch(files: string[]): void; -export function touch(options: TouchOptionsLiteral, ...files: string[]): void; -export function touch(options: TouchOptionsLiteral, files: string[]): void; -export function touch(options: touchOptionsArray, ...files: string[]): void; -export function touch(options: touchOptionsArray, files: string[]): void; +export function touch(options: TouchOptionsLiteral, ...files: (string | string[])[]): void; +export function touch(options: TouchOptionsArray, ...files: (string | string[])[]): void; // Configuration From 34b964fa9b395812ca7ec414a8ec8ed3c41e6882 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Sun, 12 Nov 2017 08:47:18 -0800 Subject: [PATCH 04/12] Use ShellString/ShellArray in shelljs --- types/shelljs/index.d.ts | 70 +++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/types/shelljs/index.d.ts b/types/shelljs/index.d.ts index ef292c1584..eda68d30de 100644 --- a/types/shelljs/index.d.ts +++ b/types/shelljs/index.d.ts @@ -19,14 +19,14 @@ export function cd(dir: string): void; * Returns the current directory. * @return The current directory. */ -export function pwd(): string; +export function pwd(): ShellString; /** * Returns array of files in the given path, or in current directory if no path provided. * @param ...paths Paths to search. * @return An array of files in the given path(s). */ -export function ls(...paths: (string | string[])[]): string[]; +export function ls(...paths: (string | string[])[]): ShellArray; /** * Returns array of files in the given path, or in current directory if no path provided. @@ -34,14 +34,14 @@ export function ls(...paths: (string | string[])[]): string[]; * @param ...paths Paths to search. * @return An array of files in the given path(s). */ -export function ls(options: string, ...paths: (string | string[])[]): string[]; +export function ls(options: string, ...paths: (string | string[])[]): ShellArray; /** * Returns array of all files (however deep) in the given paths. * @param ...path The path(s) to search. * @return An array of all files (however deep) in the given path(s). */ -export function find(...path: (string | string[])[]): string[]; +export function find(...path: (string | string[])[]): ShellArray; /** * Copies files. The wildcard * is accepted. @@ -104,7 +104,7 @@ export function test(option: string, path: string): boolean; * @param ...files Files to use. * @return A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). */ -export function cat(...files: (string | string[])[]): string; +export function cat(...files: (string | string[])[]): ShellString; /** * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. @@ -113,7 +113,7 @@ export function cat(...files: (string | string[])[]): string; * @param file The file to process. * @return The new string after replacement. */ -export function sed(searchRegex: string | RegExp, replacement: string, file: string): string; +export function sed(searchRegex: string | RegExp, replacement: string, file: string): ShellString; /** * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. @@ -123,7 +123,7 @@ export function sed(searchRegex: string | RegExp, replacement: string, file: str * @param file The file to process. * @return The new string after replacement. */ -export function sed(options: string, searchRegex: string | RegExp, replacement: string, file: string): string; +export function sed(options: string, searchRegex: string | RegExp, replacement: string, file: string): ShellString; /** * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. @@ -131,7 +131,7 @@ export function sed(options: string, searchRegex: string | RegExp, replacement: * @param ...files The files to process. * @return Returns a string containing all lines of the file that match the given regex_filter. */ -export function grep(regex_filter: string | RegExp, ...files: (string | string[])[]): string; +export function grep(regex_filter: string | RegExp, ...files: (string | string[])[]): ShellString; /** * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. @@ -140,42 +140,42 @@ export function grep(regex_filter: string | RegExp, ...files: (string | string[] * @param ...files The files to process. * @return Returns a string containing all lines of the file that match the given regex_filter. */ -export function grep(options: string, regex_filter: string | RegExp, ...files: (string | string[])[]): string; +export function grep(options: string, regex_filter: string | RegExp, ...files: (string | string[])[]): ShellString; /** * Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions. * @param command The command to search for. * @return Returns string containing the absolute path to the command. */ -export function which(command: string): string; +export function which(command: string): ShellString; /** * Prints string to stdout, and returns string with additional utility methods like .to(). * @param ...text The text to print. * @return Returns the string that was passed as argument. */ -export function echo(...text: string[]): string; +export function echo(...text: string[]): ShellString; /** * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. * @param dir Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. * @return Returns an array of paths in the stack. */ -export function pushd(dir: "+N"): string[]; +export function pushd(dir: "+N"): ShellArray; /** * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. * @param dir Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. * @return Returns an array of paths in the stack. */ -export function pushd(dir: "-N"): string[]; +export function pushd(dir: "-N"): ShellArray; /** * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. * @param dir Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir. * @return Returns an array of paths in the stack. */ -export function pushd(dir: string): string[]; +export function pushd(dir: string): ShellArray; /** * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. @@ -183,7 +183,7 @@ export function pushd(dir: string): string[]; * @param dir Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. * @return Returns an array of paths in the stack. */ -export function pushd(options: string, dir: "+N"): string[]; +export function pushd(options: string, dir: "+N"): ShellArray; /** * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. @@ -191,7 +191,7 @@ export function pushd(options: string, dir: "+N"): string[]; * @param dir Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. * @return Returns an array of paths in the stack. */ -export function pushd(options: string, dir: "-N"): string[]; +export function pushd(options: string, dir: "-N"): ShellArray; /** * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. @@ -199,34 +199,34 @@ export function pushd(options: string, dir: "-N"): string[]; * @param dir Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir. * @return Returns an array of paths in the stack. */ -export function pushd(options: string, dir: string): string[]; +export function pushd(options: string, dir: string): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. * @param dir Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. * @return Returns an array of paths in the stack. */ -export function popd(dir: "+N"): string[]; +export function popd(dir: "+N"): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. * @return Returns an array of paths in the stack. */ -export function popd(): string[]; +export function popd(): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. * @param dir Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. * @return Returns an array of paths in the stack. */ -export function popd(dir: "-N"): string[]; +export function popd(dir: "-N"): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. * @param dir You can only use -N and +N. * @return Returns an array of paths in the stack. */ -export function popd(dir: string): string[]; +export function popd(dir: string): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. @@ -234,7 +234,7 @@ export function popd(dir: string): string[]; * @param dir Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. * @return Returns an array of paths in the stack. */ -export function popd(options: string, dir: "+N"): string[]; +export function popd(options: string, dir: "+N"): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. @@ -242,7 +242,7 @@ export function popd(options: string, dir: "+N"): string[]; * @param dir Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. * @return Returns an array of paths in the stack. */ -export function popd(options: string, dir: "-N"): string[]; +export function popd(options: string, dir: "-N"): ShellArray; /** * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. @@ -250,28 +250,28 @@ export function popd(options: string, dir: "-N"): string[]; * @param dir You can only use -N and +N. * @return Returns an array of paths in the stack. */ -export function popd(options: string, dir: string): string[]; +export function popd(options: string, dir: string): ShellArray; /** * Clears the directory stack by deleting all of the elements. * @param options Clears the directory stack by deleting all of the elements. * @return Returns an array of paths in the stack, or a single path if +N or -N was specified. */ -export function dirs(options: "-c"): string[]; +export function dirs(options: "-c"): ShellArray; /** * Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified. * @param options Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. * @return Returns an array of paths in the stack, or a single path if +N or -N was specified. */ -export function dirs(options: "+N"): string; +export function dirs(options: "+N"): ShellString; /** * Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified. * @param options Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. * @return Returns an array of paths in the stack, or a single path if +N or -N was specified. */ -export function dirs(options: "-N"): string; +export function dirs(options: "-N"): ShellString; /** * Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified. @@ -359,18 +359,16 @@ export interface ShellReturnValue extends ExecOutputReturnValue { */ toEnd(file: string): void; - cat(...files: string[]): string; + cat(...files: string[]): ShellString; exec(callback: ExecCallback): child.ChildProcess; exec(): ExecOutputReturnValue; - grep(...files: (string | string[])[]): string; - sed(replacement: string, file: string): string; + grep(...files: (string | string[])[]): ShellString; + sed(replacement: string, file: string): ShellString; } -export interface ShellString extends String, ShellReturnValue { -} +type ShellString = string & ShellReturnValue; -export interface ShellArray extends Array, ShellReturnValue { -} +type ShellArray = Array & ShellReturnValue; /** @@ -397,13 +395,13 @@ export function chmod(mode: string, file: string): void; * Searches and returns string containing a writeable, platform-dependent temporary directory. Follows Python's tempfile algorithm. * @return The temp file path. */ -export function tempdir(): string; +export function tempdir(): ShellString; /** * Tests if error occurred in the last command. * @return Returns null if no error occurred, otherwise returns string explaining the error */ -export function error(): string; +export function error(): ShellString; export type TouchOptionsLiteral = "-a" | "-c" | "-m" | "-d" | "-r"; From 508530a476701c8b45236fd5b19cee514b8f123d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Sun, 12 Nov 2017 09:11:16 -0800 Subject: [PATCH 05/12] Lint:array syntax and export new types --- types/shelljs/index.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/types/shelljs/index.d.ts b/types/shelljs/index.d.ts index eda68d30de..05bb9b233b 100644 --- a/types/shelljs/index.d.ts +++ b/types/shelljs/index.d.ts @@ -26,7 +26,7 @@ export function pwd(): ShellString; * @param ...paths Paths to search. * @return An array of files in the given path(s). */ -export function ls(...paths: (string | string[])[]): ShellArray; +export function ls(...paths: Array): ShellArray; /** * Returns array of files in the given path, or in current directory if no path provided. @@ -34,14 +34,14 @@ export function ls(...paths: (string | string[])[]): ShellArray; * @param ...paths Paths to search. * @return An array of files in the given path(s). */ -export function ls(options: string, ...paths: (string | string[])[]): ShellArray; +export function ls(options: string, ...paths: Array): ShellArray; /** * Returns array of all files (however deep) in the given paths. * @param ...path The path(s) to search. * @return An array of all files (however deep) in the given path(s). */ -export function find(...path: (string | string[])[]): ShellArray; +export function find(...path: Array): ShellArray; /** * Copies files. The wildcard * is accepted. @@ -62,14 +62,14 @@ export function cp(options: string, source: string | string[], dest: string): vo * Removes files. The wildcard * is accepted. * @param ...files Files to remove. */ -export function rm(...files: (string | string[])[]): void; +export function rm(...files: Array): void; /** * Removes files. The wildcard * is accepted. * @param options Available options: -f (force), -r, -R (recursive) * @param ...files Files to remove. */ -export function rm(options: string, ...files: (string | string[])[]): void; +export function rm(options: string, ...files: Array): void; /** * Moves files. The wildcard * is accepted. @@ -82,14 +82,14 @@ export function mv(source: string | string[], dest: string): void; * Creates directories. * @param ...dir Directories to create. */ -export function mkdir(...dir: (string | string[])[]): void; +export function mkdir(...dir: Array): void; /** * Creates directories. * @param options Available options: p (full paths, will create intermediate dirs if necessary) * @param ...dir The directories to create. */ -export function mkdir(options: string, ...dir: (string | string[])[]): void; +export function mkdir(options: string, ...dir: Array): void; /** * Evaluates expression using the available primaries and returns corresponding value. @@ -104,7 +104,7 @@ export function test(option: string, path: string): boolean; * @param ...files Files to use. * @return A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). */ -export function cat(...files: (string | string[])[]): ShellString; +export function cat(...files: Array): ShellString; /** * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement. @@ -131,7 +131,7 @@ export function sed(options: string, searchRegex: string | RegExp, replacement: * @param ...files The files to process. * @return Returns a string containing all lines of the file that match the given regex_filter. */ -export function grep(regex_filter: string | RegExp, ...files: (string | string[])[]): ShellString; +export function grep(regex_filter: string | RegExp, ...files: Array): ShellString; /** * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted. @@ -140,7 +140,7 @@ export function grep(regex_filter: string | RegExp, ...files: (string | string[] * @param ...files The files to process. * @return Returns a string containing all lines of the file that match the given regex_filter. */ -export function grep(options: string, regex_filter: string | RegExp, ...files: (string | string[])[]): ShellString; +export function grep(options: string, regex_filter: string | RegExp, ...files: Array): ShellString; /** * Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions. @@ -362,13 +362,13 @@ export interface ShellReturnValue extends ExecOutputReturnValue { cat(...files: string[]): ShellString; exec(callback: ExecCallback): child.ChildProcess; exec(): ExecOutputReturnValue; - grep(...files: (string | string[])[]): ShellString; + grep(...files: Array): ShellString; sed(replacement: string, file: string): ShellString; } -type ShellString = string & ShellReturnValue; +export type ShellString = string & ShellReturnValue; -type ShellArray = Array & ShellReturnValue; +export type ShellArray = Array & ShellReturnValue; /** @@ -415,8 +415,8 @@ export interface TouchOptionsArray { export function touch(...files: string[]): void; export function touch(files: string[]): void; -export function touch(options: TouchOptionsLiteral, ...files: (string | string[])[]): void; -export function touch(options: TouchOptionsArray, ...files: (string | string[])[]): void; +export function touch(options: TouchOptionsLiteral, ...files: Array): void; +export function touch(options: TouchOptionsArray, ...files: Array): void; // Configuration From 0c926706cc38f551dbde565ac317f2dd1033dcbe Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Sun, 12 Nov 2017 09:17:51 -0800 Subject: [PATCH 06/12] Lint:blank line and more array type fussiness --- types/shelljs/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/shelljs/index.d.ts b/types/shelljs/index.d.ts index 05bb9b233b..c425ac6180 100644 --- a/types/shelljs/index.d.ts +++ b/types/shelljs/index.d.ts @@ -368,8 +368,7 @@ export interface ShellReturnValue extends ExecOutputReturnValue { export type ShellString = string & ShellReturnValue; -export type ShellArray = Array & ShellReturnValue; - +export type ShellArray = string[] & ShellReturnValue; /** * Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions: From 3448aae7faac8925c2b392db9a91f91381ddb311 Mon Sep 17 00:00:00 2001 From: King Wang Date: Mon, 13 Nov 2017 11:58:51 +0800 Subject: [PATCH 07/12] Update index.d.ts --- types/showdown/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index cb3b9ae088..3a1accb411 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -298,7 +298,7 @@ declare namespace Showdown { * Setting a "local" option only affects the specified Converter object. * * @param optionKey - * @param string + * @param value */ setOption(optionKey: string, value: any): void; From bd4e79efd4ded82d3bb95b308d78e947628307d6 Mon Sep 17 00:00:00 2001 From: Jimi van der Woning Date: Mon, 13 Nov 2017 11:19:45 +0100 Subject: [PATCH 08/12] feat: add definitions for gzip-size v4 --- types/gzip-size/index.d.ts | 16 ++++++++++----- types/gzip-size/v3/gzip-size-tests.ts | 7 +++++++ types/gzip-size/v3/index.d.ts | 13 +++++++++++++ types/gzip-size/v3/tsconfig.json | 28 +++++++++++++++++++++++++++ types/gzip-size/v3/tslint.json | 3 +++ 5 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 types/gzip-size/v3/gzip-size-tests.ts create mode 100644 types/gzip-size/v3/index.d.ts create mode 100644 types/gzip-size/v3/tsconfig.json create mode 100644 types/gzip-size/v3/tslint.json diff --git a/types/gzip-size/index.d.ts b/types/gzip-size/index.d.ts index 12b1899b54..cab8ec225b 100644 --- a/types/gzip-size/index.d.ts +++ b/types/gzip-size/index.d.ts @@ -1,13 +1,19 @@ -// Type definitions for gzip-size 3.0 +// Type definitions for gzip-size 4.0 // Project: https://github.com/sindresorhus/gzip-size // Definitions by: York Yao +// Jimi van der Woning // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare function gzipSize(input: string | Buffer, callback: (error: Error, size: number) => void): string; -export = gzipSize; +import * as stream from 'stream'; +import * as zlib from 'zlib'; + +declare function gzipSize(input: string | Buffer, options?: zlib.ZlibOptions): Promise; + declare namespace gzipSize { - function sync(input: string | Buffer): number; - function stream(): NodeJS.ReadWriteStream; + function sync(input: string | Buffer, options?: zlib.ZlibOptions): number; + function stream(options?: zlib.ZlibOptions): stream.PassThrough; } + +export = gzipSize; diff --git a/types/gzip-size/v3/gzip-size-tests.ts b/types/gzip-size/v3/gzip-size-tests.ts new file mode 100644 index 0000000000..f07d99bd50 --- /dev/null +++ b/types/gzip-size/v3/gzip-size-tests.ts @@ -0,0 +1,7 @@ +import gzipSize = require('gzip-size'); + +const string = 'Lorem ipsum dolor sit amet.'; + +console.log(string.length); + +console.log(gzipSize.sync(string)); diff --git a/types/gzip-size/v3/index.d.ts b/types/gzip-size/v3/index.d.ts new file mode 100644 index 0000000000..12b1899b54 --- /dev/null +++ b/types/gzip-size/v3/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for gzip-size 3.0 +// Project: https://github.com/sindresorhus/gzip-size +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function gzipSize(input: string | Buffer, callback: (error: Error, size: number) => void): string; +export = gzipSize; +declare namespace gzipSize { + function sync(input: string | Buffer): number; + function stream(): NodeJS.ReadWriteStream; +} diff --git a/types/gzip-size/v3/tsconfig.json b/types/gzip-size/v3/tsconfig.json new file mode 100644 index 0000000000..88a695711b --- /dev/null +++ b/types/gzip-size/v3/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "gzip-size": [ + "gzip-size/v3" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gzip-size-tests.ts" + ] +} diff --git a/types/gzip-size/v3/tslint.json b/types/gzip-size/v3/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/gzip-size/v3/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From 112cd72e92b7dd3cfbaa0e7c9fadaad50f9618cd Mon Sep 17 00:00:00 2001 From: Confidential Date: Mon, 13 Nov 2017 16:55:30 +0200 Subject: [PATCH 09/12] Create definitions for gulp-jasmine@2.4 (#21431) * Create definitions for gulp-jasmine@2.4 * Fix the 'reporter' property Functionality: - Make the secondary type of the 'reporter' property in JasmineOptions ReadonlyArray instead of jasmine.CustomReporter[]. Tests: - Add some more tests Testing done: npm run lint gulp-jasmine (with and without the change to verify the tests fail properly) * Remove unnecessary empty namespace. --- types/gulp-jasmine/gulp-jasmine-tests.ts | 20 ++++++++++ types/gulp-jasmine/index.d.ts | 50 ++++++++++++++++++++++++ types/gulp-jasmine/tsconfig.json | 23 +++++++++++ types/gulp-jasmine/tslint.json | 1 + 4 files changed, 94 insertions(+) create mode 100644 types/gulp-jasmine/gulp-jasmine-tests.ts create mode 100644 types/gulp-jasmine/index.d.ts create mode 100644 types/gulp-jasmine/tsconfig.json create mode 100644 types/gulp-jasmine/tslint.json diff --git a/types/gulp-jasmine/gulp-jasmine-tests.ts b/types/gulp-jasmine/gulp-jasmine-tests.ts new file mode 100644 index 0000000000..e40f187004 --- /dev/null +++ b/types/gulp-jasmine/gulp-jasmine-tests.ts @@ -0,0 +1,20 @@ +import gulpJasmine = require("gulp-jasmine"); +import jasmine = require("jasmine"); + +const dummyReporter: jasmine.CustomReporter = {}; + +gulpJasmine(); // $ExpectType ReadWriteStream +gulpJasmine({}); +gulpJasmine({ + verbose: true, + includeStackTrace: true, + reporter: dummyReporter, + timeout: 1000, + errorOnFail: false, + config: {} +}); +gulpJasmine({ reporter: [dummyReporter, dummyReporter] }); +const readonlyDummyReporters: ReadonlyArray = [ + dummyReporter, dummyReporter +]; +gulpJasmine({ reporter: readonlyDummyReporters }); diff --git a/types/gulp-jasmine/index.d.ts b/types/gulp-jasmine/index.d.ts new file mode 100644 index 0000000000..f69fb865e6 --- /dev/null +++ b/types/gulp-jasmine/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for gulp-jasmine 2.4 +// Project: https://github.com/sindresorhus/gulp-jasmine#readme +// Definitions by: Andrey Lalev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// +/// + +interface JasmineOptions { + /** + * Display spec names in default reporter. + */ + verbose?: boolean; + + /** + * Include stack traces in failures in default reporter. + * @default false + */ + includeStackTrace?: boolean; + + /** + * Reporter(s) to use. + */ + reporter?: jasmine.CustomReporter | ReadonlyArray; + + /** + * Time to wait in milliseconds before a test automatically fails. + * @default 5000 + */ + timeout?: number; + + /** + * Stops the stream on failed tests. + * @default true + */ + errorOnFail?: boolean; + + /** + * Passes the config to Jasmine's loadConfig method. + */ + config?: object; +} + +/** + * Executes Jasmine tests. Emits a 'jasmineDone' event on success. + * @param options Optional options for the execution of the Jasmine test + */ +declare function gulpJasmine(options?: JasmineOptions): NodeJS.ReadWriteStream; +export = gulpJasmine; diff --git a/types/gulp-jasmine/tsconfig.json b/types/gulp-jasmine/tsconfig.json new file mode 100644 index 0000000000..d44751f20b --- /dev/null +++ b/types/gulp-jasmine/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gulp-jasmine-tests.ts" + ] +} diff --git a/types/gulp-jasmine/tslint.json b/types/gulp-jasmine/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gulp-jasmine/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From f8e25077c305bc2c5fc7504b2ce4fe5eea3ba469 Mon Sep 17 00:00:00 2001 From: Alec Winograd Date: Mon, 13 Nov 2017 15:56:27 +0100 Subject: [PATCH 10/12] Add loading spinner props to react-native-elements ButtonProps (#21382) * Add loading spinner props to react-native-elements ButtonProps https://react-native-training.github.io/react-native-elements/API/buttons/ * Fix lint error --- types/react-native-elements/index.d.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/types/react-native-elements/index.d.ts b/types/react-native-elements/index.d.ts index 60afbdf38d..821e9b65e7 100644 --- a/types/react-native-elements/index.d.ts +++ b/types/react-native-elements/index.d.ts @@ -354,11 +354,25 @@ export interface ButtonProps extends TouchableWithoutFeedbackProps { containerViewStyle?: StyleProp; /** - * Indicates button is loading + * Styling for loading spinner + * + * @default null + */ + activityIndicatorStyle?: StyleProp; + + /** + * Display a loading spinner * * @default false */ loading?: boolean; + + /** + * Display the spinner to the right + * + * @default false + */ + loadingRight?: boolean; } /** From 938afa59ccfcbac7a6a5d4c1d25f73a402d00eb9 Mon Sep 17 00:00:00 2001 From: Sean Tan Date: Mon, 13 Nov 2017 22:58:14 +0800 Subject: [PATCH 11/12] [puppeteer] Fix return signatures that contain null (#21424) --- types/puppeteer/index.d.ts | 14 +++++++------- types/puppeteer/puppeteer-tests.ts | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index 8479c100a1..2c803966db 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -202,7 +202,7 @@ export interface BoundingBox { } export interface ElementHandle extends JSHandle { - boundingBox(): BoundingBox; + boundingBox(): BoundingBox | null; click(options?: ClickOptions): Promise; focus(): Promise; hover(): Promise; @@ -227,7 +227,7 @@ export interface ExecutionContext { } export interface JSHandle { - asElement(): ElementHandle; + asElement(): ElementHandle | null; dispose(): Promise; executionContext(): ExecutionContext; getProperties(): Promise>; @@ -305,7 +305,7 @@ export interface Response { } export interface FrameBase { - $(selector: string): Promise; + $(selector: string): Promise; $$(selector: string): Promise; $$eval( selector: string, @@ -349,7 +349,7 @@ export interface Frame extends FrameBase { executionContext(): ExecutionContext; isDetached(): boolean; name(): string; - parentFrame(): Frame | undefined; + parentFrame(): Frame | null; } export interface EventObj { @@ -396,9 +396,9 @@ export interface Page extends FrameBase { focus(selector: string): Promise; frames(): Frame[]; getMetrics(): Metrics; - goBack(options?: Partial): Promise; - goForward(options?: Partial): Promise; - goto(url: string, options?: Partial): Promise; + goBack(options?: Partial): Promise; + goForward(options?: Partial): Promise; + goto(url: string, options?: Partial): Promise; hover(selector: string): Promise; keyboard: Keyboard; mainFrame(): Frame; diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 9d76178a62..57580f1561 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -151,7 +151,7 @@ puppeteer.launch().then(async browser => { }); const inputElement = await page.$("input[type=submit]"); - await inputElement.click(); + if (inputElement) await inputElement.click(); }); // Example with launch options @@ -178,9 +178,9 @@ puppeteer.launch().then(async browser => { } }); const page = await browser.newPage(); - const button = await page.$("#myButton"); - const div = await page.$("#myDiv"); - const input = await page.$("#myInput"); + const button = (await page.$("#myButton"))!; + const div = (await page.$("#myDiv"))!; + const input = (await page.$("#myInput"))!; await page.addStyleTag({ url: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" @@ -223,7 +223,7 @@ puppeteer.launch().then(async browser => { console.log(navResponse.ok, navResponse.status, navResponse.url, navResponse.headers); // evaluate example - const bodyHandle = await page.$('body'); + const bodyHandle = (await page.$('body'))!; const html = await page.evaluate(body => body.innerHTML, bodyHandle); await bodyHandle.dispose(); From 92db6df0e8be6f7e60d82d78238c610ada88b908 Mon Sep 17 00:00:00 2001 From: Shane Fitzpatrick Date: Mon, 13 Nov 2017 14:12:32 -0800 Subject: [PATCH 12/12] react-native: Adding missing GeoLocation function: setRNConfiguration --- types/react-native/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 1c0cb7d0e8..ba92c33cd4 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -618,6 +618,10 @@ export interface ShadowPropTypesIOSStatic { shadowRadius: number } +type GeoConfiguration = { + skipPermissionRequests: boolean; +} + type GeoOptions = { timeout?: number, maximumAge?: number, @@ -8089,6 +8093,8 @@ export interface GeolocationStatic { stopObserving(): void requestAuthorization(): void; + + setRNConfiguration(config: GeoConfiguration): void; } export interface OpenCameraDialogOptions {