From 40721b847ab1d4838564f7e83c967b9fcc543149 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 22 Oct 2018 16:40:23 -0700 Subject: [PATCH] Use ts.generateTypesForModule --- baselines/expr-someClass.d.ts | 8 +- baselines/module-ecurve.d.ts | 19 +- baselines/module-fs.d.ts | 323 +++++++++++--- baselines/module-lodash.d.ts | 775 ++++++++++++++-------------------- baselines/module-path.d.ts | 678 +---------------------------- baselines/module-yargs.d.ts | 7 +- lib/index.ts | 414 +----------------- lib/run.ts | 4 +- package.json | 1 - tests/test.ts | 2 +- 10 files changed, 626 insertions(+), 1605 deletions(-) diff --git a/baselines/expr-someClass.d.ts b/baselines/expr-someClass.d.ts index 550008c..d5432fe 100644 --- a/baselines/expr-someClass.d.ts +++ b/baselines/expr-someClass.d.ts @@ -1,6 +1,8 @@ declare class someClass { - constructor(arg: any); - prototypeMethod(p: any): void; - static staticMethod(s: any): void; + static staticMethod(_s: any): void; static staticNum: number; + constructor(arg: any); + arg: any; + instanceStr: any; + prototypeMethod(_p: any): void; } diff --git a/baselines/module-ecurve.d.ts b/baselines/module-ecurve.d.ts index 87c6fe5..be4f73a 100644 --- a/baselines/module-ecurve.d.ts +++ b/baselines/module-ecurve.d.ts @@ -1,21 +1,34 @@ export class Curve { constructor(p: any, a: any, b: any, Gx: any, Gy: any, n: any, h: any); + p: any; + a: any; + b: any; + G: any; + n: any; + h: any; + infinity: any; + pOverFour: any; + pLength: any; isInfinity(Q: any): any; isOnCurve(Q: any): any; pointFromX(isOdd: any, x: any): any; validate(Q: any): any; } export class Point { + static decodeFrom(curve: any, buffer: any): any; + static fromAffine(curve: any, x: any, y: any): any; constructor(curve: any, x: any, y: any, z: any); + curve: any; + x: any; + y: any; + z: any; + compressed: any; add(b: any): any; equals(other: any): any; getEncoded(compressed: any): any; multiply(k: any): any; multiplyTwo(j: any, x: any, k: any): any; negate(): any; - toString(): any; twice(): any; - static decodeFrom(curve: any, buffer: any): any; - static fromAffine(curve: any, x: any, y: any): any; } export function getCurveByName(name: any): any; diff --git a/baselines/module-fs.d.ts b/baselines/module-fs.d.ts index ace3dc4..25e236b 100644 --- a/baselines/module-fs.d.ts +++ b/baselines/module-fs.d.ts @@ -1,24 +1,162 @@ +export class Dirent { + constructor(name: any, type: any); + name: any; + isBlockDevice(): any; + isCharacterDevice(): any; + isDirectory(): any; + isFIFO(): any; + isFile(): any; + isSocket(): any; + isSymbolicLink(): any; +} +export const F_OK: number; export class FileReadStream { constructor(path: any, options: any); - close(cb: any): any; - destroy(): void; + path: any; + fd: any; + flags: any; + mode: any; + start: any; + end: any; + autoClose: any; + pos: any; + bytesRead: any; + closed: any; + end: any; + pos: any; + end: any; + addListener(ev: any, fn: any): any; + close(cb: any): void; + destroy(err: any, cb: any): any; + emit(type: any, args: any): any; + eventNames(): any; + getMaxListeners(): any; + isPaused(): any; + listenerCount(type: any): any; + listeners(type: any): any; + off(type: any, listener: any): any; + on(ev: any, fn: any): any; + once(type: any, listener: any): any; open(): void; + pause(): any; + pipe(dest: any, pipeOpts: any): any; + prependListener(type: any, listener: any): any; + prependOnceListener(type: any, listener: any): any; + push(chunk: any, encoding: any): any; + rawListeners(type: any): any; + read(n: any): any; + removeAllListeners(ev: any, ...args: any[]): any; + removeListener(ev: any, fn: any): any; + resume(): any; + setEncoding(enc: any): any; + setMaxListeners(n: any): any; + unpipe(dest: any): any; + unshift(chunk: any): any; + wrap(stream: any): any; } export class FileWriteStream { constructor(path: any, options: any); - close(cb: any): any; - destroy(): void; - destroySoon(chunk: any, encoding: any, cb: any): void; + path: any; + fd: any; + flags: any; + mode: any; + start: any; + autoClose: any; + pos: any; + bytesWritten: any; + closed: any; + pos: any; + addListener(type: any, listener: any): any; + close(cb: any): void; + cork(): void; + destroy(err: any, cb: any): any; + destroySoon(chunk: any, encoding: any, cb: any): any; + emit(type: any, args: any): any; + end(chunk: any, encoding: any, cb: any): any; + eventNames(): any; + getMaxListeners(): any; + listenerCount(type: any): any; + listeners(type: any): any; + off(type: any, listener: any): any; + on(type: any, listener: any): any; + once(type: any, listener: any): any; open(): void; + pipe(): void; + prependListener(type: any, listener: any): any; + prependOnceListener(type: any, listener: any): any; + rawListeners(type: any): any; + removeAllListeners(type: any, ...args: any[]): any; + removeListener(type: any, listener: any): any; + setDefaultEncoding(encoding: any): any; + setMaxListeners(n: any): any; + uncork(): void; + write(chunk: any, encoding: any, cb: any): any; } +export const R_OK: number; export class ReadStream { constructor(path: any, options: any); - close(cb: any): any; - destroy(): void; + path: any; + fd: any; + flags: any; + mode: any; + start: any; + end: any; + autoClose: any; + pos: any; + bytesRead: any; + closed: any; + end: any; + pos: any; + end: any; + addListener(ev: any, fn: any): any; + close(cb: any): void; + destroy(err: any, cb: any): any; + emit(type: any, args: any): any; + eventNames(): any; + getMaxListeners(): any; + isPaused(): any; + listenerCount(type: any): any; + listeners(type: any): any; + off(type: any, listener: any): any; + on(ev: any, fn: any): any; + once(type: any, listener: any): any; open(): void; + pause(): any; + pipe(dest: any, pipeOpts: any): any; + prependListener(type: any, listener: any): any; + prependOnceListener(type: any, listener: any): any; + push(chunk: any, encoding: any): any; + rawListeners(type: any): any; + read(n: any): any; + removeAllListeners(ev: any, ...args: any[]): any; + removeListener(ev: any, fn: any): any; + resume(): any; + setEncoding(enc: any): any; + setMaxListeners(n: any): any; + unpipe(dest: any): any; + unshift(chunk: any): any; + wrap(stream: any): any; } export class Stats { constructor(dev: any, mode: any, nlink: any, uid: any, gid: any, rdev: any, blksize: any, ino: any, size: any, blocks: any, atim_msec: any, mtim_msec: any, ctim_msec: any, birthtim_msec: any); + dev: any; + mode: any; + nlink: any; + uid: any; + gid: any; + rdev: any; + blksize: any; + ino: any; + size: any; + blocks: any; + atimeMs: any; + mtimeMs: any; + ctimeMs: any; + birthtimeMs: any; + atime: any; + mtime: any; + ctime: any; + birthtime: any; isBlockDevice(): any; isCharacterDevice(): any; isDirectory(): any; @@ -27,106 +165,183 @@ export class Stats { isSocket(): any; isSymbolicLink(): any; } -export class SyncWriteStream { - constructor(fd: any, options: any); - destroy(): any; - destroySoon(): any; -} +export const SyncWriteStream: any; +export const W_OK: number; export class WriteStream { constructor(path: any, options: any); - close(cb: any): any; - destroy(): void; - destroySoon(chunk: any, encoding: any, cb: any): void; + path: any; + fd: any; + flags: any; + mode: any; + start: any; + autoClose: any; + pos: any; + bytesWritten: any; + closed: any; + pos: any; + addListener(type: any, listener: any): any; + close(cb: any): void; + cork(): void; + destroy(err: any, cb: any): any; + destroySoon(chunk: any, encoding: any, cb: any): any; + emit(type: any, args: any): any; + end(chunk: any, encoding: any, cb: any): any; + eventNames(): any; + getMaxListeners(): any; + listenerCount(type: any): any; + listeners(type: any): any; + off(type: any, listener: any): any; + on(type: any, listener: any): any; + once(type: any, listener: any): any; open(): void; + pipe(): void; + prependListener(type: any, listener: any): any; + prependOnceListener(type: any, listener: any): any; + rawListeners(type: any): any; + removeAllListeners(type: any, ...args: any[]): any; + removeListener(type: any, listener: any): any; + setDefaultEncoding(encoding: any): any; + setMaxListeners(n: any): any; + uncork(): void; + write(chunk: any, encoding: any, cb: any): any; } -export const F_OK: number; -export const R_OK: number; -export const W_OK: number; export const X_OK: number; +export function access(path: any, mode: any, callback: any): void; +export function accessSync(path: any, mode: any): void; +export function appendFile(path: any, data: any, options: any, callback: any): void; +export function appendFileSync(path: any, data: any, options: any): void; +export function chmod(path: any, mode: any, callback: any): void; +export function chmodSync(path: any, mode: any): void; +export function chown(path: any, uid: any, gid: any, callback: any): void; +export function chownSync(path: any, uid: any, gid: any): void; +export function close(fd: any, callback: any): void; +export function closeSync(fd: any): void; export const constants: { + COPYFILE_EXCL: number; + COPYFILE_FICLONE: number; + COPYFILE_FICLONE_FORCE: number; F_OK: number; O_APPEND: number; O_CREAT: number; + O_DIRECT: number; + O_DIRECTORY: number; + O_DSYNC: number; O_EXCL: number; + O_NOATIME: number; + O_NOCTTY: number; + O_NOFOLLOW: number; + O_NONBLOCK: number; O_RDONLY: number; O_RDWR: number; + O_SYNC: number; O_TRUNC: number; O_WRONLY: number; R_OK: number; + S_IFBLK: number; S_IFCHR: number; S_IFDIR: number; + S_IFIFO: number; S_IFLNK: number; S_IFMT: number; S_IFREG: number; + S_IFSOCK: number; + S_IRGRP: number; + S_IROTH: number; + S_IRUSR: number; + S_IRWXG: number; + S_IRWXO: number; + S_IRWXU: number; + S_IWGRP: number; + S_IWOTH: number; + S_IWUSR: number; + S_IXGRP: number; + S_IXOTH: number; + S_IXUSR: number; + UV_DIRENT_BLOCK: number; + UV_DIRENT_CHAR: number; + UV_DIRENT_DIR: number; + UV_DIRENT_FIFO: number; + UV_DIRENT_FILE: number; + UV_DIRENT_LINK: number; + UV_DIRENT_SOCKET: number; + UV_DIRENT_UNKNOWN: number; + UV_FS_COPYFILE_EXCL: number; + UV_FS_COPYFILE_FICLONE: number; + UV_FS_COPYFILE_FICLONE_FORCE: number; + UV_FS_SYMLINK_DIR: number; + UV_FS_SYMLINK_JUNCTION: number; W_OK: number; X_OK: number; }; -export function access(path: any, mode: any, callback: any): void; -export function accessSync(path: any, mode: any): void; -export function appendFile(path: any, data: any, options: any, callback_: any, ...args: any[]): void; -export function appendFileSync(path: any, data: any, options: any): void; -export function chmod(path: any, mode: any, callback: any): void; -export function chmodSync(path: any, mode: any): any; -export function chown(path: any, uid: any, gid: any, callback: any): void; -export function chownSync(path: any, uid: any, gid: any): any; -export function close(fd: any, callback: any): void; -export function closeSync(fd: any): any; +export function copyFile(src: any, dest: any, flags: any, callback: any): void; +export function copyFileSync(src: any, dest: any, flags: any): void; export function createReadStream(path: any, options: any): any; export function createWriteStream(path: any, options: any): any; -export function exists(path: any, callback: any): void; +export function exists(path: any, callback: any): any; export function existsSync(path: any): any; export function fchmod(fd: any, mode: any, callback: any): void; -export function fchmodSync(fd: any, mode: any): any; +export function fchmodSync(fd: any, mode: any): void; export function fchown(fd: any, uid: any, gid: any, callback: any): void; -export function fchownSync(fd: any, uid: any, gid: any): any; +export function fchownSync(fd: any, uid: any, gid: any): void; export function fdatasync(fd: any, callback: any): void; -export function fdatasyncSync(fd: any): any; -export function fstat(fd: any, callback: any): void; -export function fstatSync(fd: any): any; +export function fdatasyncSync(fd: any): void; +export function fstat(fd: any, options: any, callback: any, ...args: any[]): void; +export function fstatSync(fd: any, options: any): any; export function fsync(fd: any, callback: any): void; -export function fsyncSync(fd: any): any; +export function fsyncSync(fd: any): void; export function ftruncate(fd: any, len: any, callback: any): void; -export function ftruncateSync(fd: any, len: any): any; +export function ftruncateSync(fd: any, len: any): void; export function futimes(fd: any, atime: any, mtime: any, callback: any): void; export function futimesSync(fd: any, atime: any, mtime: any): void; -export function link(srcpath: any, dstpath: any, callback: any): void; -export function linkSync(srcpath: any, dstpath: any): any; -export function lstat(path: any, callback: any): void; -export function lstatSync(path: any): any; -export function mkdir(path: any, mode: any, callback: any): void; -export function mkdirSync(path: any, mode: any): any; +export const lchmod: any; +export const lchmodSync: any; +export function lchown(path: any, uid: any, gid: any, callback: any): void; +export function lchownSync(path: any, uid: any, gid: any): void; +export function link(existingPath: any, newPath: any, callback: any): void; +export function linkSync(existingPath: any, newPath: any): any; +export function lstat(path: any, options: any, callback: any, ...args: any[]): void; +export function lstatSync(path: any, options: any): any; +export function mkdir(path: any, mode: any, callback: any, ...args: any[]): void; +export function mkdirSync(path: any, mode: any): void; export function mkdtemp(prefix: any, options: any, callback: any): void; export function mkdtempSync(prefix: any, options: any): any; -export function open(path: any, flags: any, mode: any, callback_: any, ...args: any[]): void; +export function open(path: any, flags: any, mode: any, callback: any, ...args: any[]): void; export function openSync(path: any, flags: any, mode: any): any; -export function read(fd: any, buffer: any, offset: any, length: any, position: any, callback: any, ...args: any[]): any; -export function readFile(path: any, options: any, callback_: any, ...args: any[]): void; +export const promises: any; +export function read(fd: any, buffer: any, offset: any, length: any, position: any, callback: any): any; +export function readFile(path: any, options: any, callback: any): void; export function readFileSync(path: any, options: any): any; -export function readSync(fd: any, buffer: any, offset: any, length: any, position: any, ...args: any[]): any; +export function readSync(fd: any, buffer: any, offset: any, length: any, position: any): any; export function readdir(path: any, options: any, callback: any): void; export function readdirSync(path: any, options: any): any; export function readlink(path: any, options: any, callback: any): void; export function readlinkSync(path: any, options: any): any; -export function realpath(p: any, options: any, callback: any): any; +export function realpath(p: any, options: any, callback: any): void; +export namespace realpath { + function native(path: any, options: any, callback: any): any; +} export function realpathSync(p: any, options: any): any; +export namespace realpathSync { + function native(path: any, options: any): any; +} export function rename(oldPath: any, newPath: any, callback: any): void; -export function renameSync(oldPath: any, newPath: any): any; +export function renameSync(oldPath: any, newPath: any): void; export function rmdir(path: any, callback: any): void; -export function rmdirSync(path: any): any; -export function stat(path: any, callback: any): void; -export function statSync(path: any): any; +export function rmdirSync(path: any): void; +export function stat(path: any, options: any, callback: any, ...args: any[]): void; +export function statSync(path: any, options: any): any; export function symlink(target: any, path: any, type_: any, callback_: any, ...args: any[]): void; -export function symlinkSync(target: any, path: any, type: any): any; +export function symlinkSync(target: any, path: any, type: any): void; export function truncate(path: any, len: any, callback: any): any; export function truncateSync(path: any, len: any): any; export function unlink(path: any, callback: any): void; -export function unlinkSync(path: any): any; +export function unlinkSync(path: any): void; export function unwatchFile(filename: any, listener: any): void; export function utimes(path: any, atime: any, mtime: any, callback: any): void; export function utimesSync(path: any, atime: any, mtime: any): void; export function watch(filename: any, options: any, listener: any): any; export function watchFile(filename: any, options: any, listener: any): any; export function write(fd: any, buffer: any, offset: any, length: any, position: any, callback: any): any; -export function writeFile(path: any, data: any, options: any, callback_: any, ...args: any[]): void; +export function writeFile(path: any, data: any, options: any, callback: any): void; export function writeFileSync(path: any, data: any, options: any): void; export function writeSync(fd: any, buffer: any, offset: any, length: any, position: any): any; diff --git a/baselines/module-lodash.d.ts b/baselines/module-lodash.d.ts index fda512d..1358429 100644 --- a/baselines/module-lodash.d.ts +++ b/baselines/module-lodash.d.ts @@ -1,6 +1,312 @@ export = lodash; declare class lodash { - constructor(...args: any[]); + static VERSION: string; + static add(value: any, other: any): any; + static after(n: any, func: any): any; + static ary(func: any, n: any, guard: any): any; + static assign(...args: any[]): any; + static assignIn(...args: any[]): any; + static assignInWith(...args: any[]): any; + static assignWith(...args: any[]): any; + static at(...args: any[]): any; + static attempt(...args: any[]): any; + static before(n: any, func: any): any; + static bindAll(...args: any[]): any; + static camelCase(string: any): any; + static capitalize(string: any): any; + static castArray(...args: any[]): any; + static ceil(number: any, precision: any): any; + static chain(value: any): any; + static chunk(array: any, size: any, guard: any): any; + static clamp(number: any, lower: any, upper: any): any; + static clone(value: any): any; + static cloneDeep(value: any): any; + static cloneDeepWith(value: any, customizer: any): any; + static cloneWith(value: any, customizer: any): any; + static compact(array: any): any; + static concat(...args: any[]): any; + static cond(pairs: any): any; + static conforms(source: any): any; + static conformsTo(object: any, source: any): any; + static constant(value: any): any; + static countBy(collection: any, iteratee: any): any; + static create(prototype: any, properties: any): any; + static debounce(func: any, wait: any, options: any): any; + static deburr(string: any): any; + static defaultTo(value: any, defaultValue: any): any; + static defaults(...args: any[]): any; + static defaultsDeep(...args: any[]): any; + static defer(...args: any[]): any; + static delay(...args: any[]): any; + static difference(...args: any[]): any; + static differenceBy(...args: any[]): any; + static differenceWith(...args: any[]): any; + static divide(value: any, other: any): any; + static drop(array: any, n: any, guard: any): any; + static dropRight(array: any, n: any, guard: any): any; + static dropRightWhile(array: any, predicate: any): any; + static dropWhile(array: any, predicate: any): any; + static each(collection: any, iteratee: any): any; + static eachRight(collection: any, iteratee: any): any; + static endsWith(string: any, target: any, position: any): any; + static entries(object: any): any; + static entriesIn(object: any): any; + static eq(value: any, other: any): any; + static escape(string: any): any; + static escapeRegExp(string: any): any; + static every(collection: any, predicate: any, guard: any): any; + static extend(...args: any[]): any; + static extendWith(...args: any[]): any; + static fill(array: any, value: any, start: any, end: any): any; + static filter(collection: any, predicate: any): any; + static find(collection: any, predicate: any, fromIndex: any): any; + static findIndex(array: any, predicate: any, fromIndex: any): any; + static findKey(object: any, predicate: any): any; + static findLast(collection: any, predicate: any, fromIndex: any): any; + static findLastIndex(array: any, predicate: any, fromIndex: any): any; + static findLastKey(object: any, predicate: any): any; + static first(array: any): any; + static flatMap(collection: any, iteratee: any): any; + static flatMapDeep(collection: any, iteratee: any): any; + static flatMapDepth(collection: any, iteratee: any, depth: any): any; + static flatten(array: any): any; + static flattenDeep(array: any): any; + static flattenDepth(array: any, depth: any): any; + static flip(func: any): any; + static floor(number: any, precision: any): any; + static flow(...args: any[]): any; + static flowRight(...args: any[]): any; + static forEach(collection: any, iteratee: any): any; + static forEachRight(collection: any, iteratee: any): any; + static forIn(object: any, iteratee: any): any; + static forInRight(object: any, iteratee: any): any; + static forOwn(object: any, iteratee: any): any; + static forOwnRight(object: any, iteratee: any): any; + static fromPairs(pairs: any): any; + static functions(object: any): any; + static functionsIn(object: any): any; + static get(object: any, path: any, defaultValue: any): any; + static groupBy(collection: any, iteratee: any): any; + static gt(value: any, other: any): any; + static gte(value: any, other: any): any; + static has(object: any, path: any): any; + static hasIn(object: any, path: any): any; + static head(array: any): any; + static identity(value: any): any; + static inRange(number: any, start: any, end: any): any; + static includes(collection: any, value: any, fromIndex: any, guard: any): any; + static indexOf(array: any, value: any, fromIndex: any): any; + static initial(array: any): any; + static intersection(...args: any[]): any; + static intersectionBy(...args: any[]): any; + static intersectionWith(...args: any[]): any; + static invert(object: any, iteratee: any): any; + static invertBy(object: any, iteratee: any): any; + static invoke(...args: any[]): any; + static invokeMap(...args: any[]): any; + static isArguments(value: any): any; + static isArray(p0: any): any; + static isArrayBuffer(value: any): any; + static isArrayLike(value: any): any; + static isArrayLikeObject(value: any): any; + static isBoolean(value: any): any; + static isBuffer(b: any): any; + static isDate(value: any): any; + static isElement(value: any): any; + static isEmpty(value: any): any; + static isEqual(value: any, other: any): any; + static isEqualWith(value: any, other: any, customizer: any): any; + static isError(value: any): any; + static isFinite(value: any): any; + static isFunction(value: any): any; + static isInteger(value: any): any; + static isLength(value: any): any; + static isMap(value: any): any; + static isMatch(object: any, source: any): any; + static isMatchWith(object: any, source: any, customizer: any): any; + static isNaN(value: any): any; + static isNative(value: any): any; + static isNil(value: any): any; + static isNull(value: any): any; + static isNumber(value: any): any; + static isObject(value: any): any; + static isObjectLike(value: any): any; + static isPlainObject(value: any): any; + static isRegExp(value: any): any; + static isSafeInteger(value: any): any; + static isSet(value: any): any; + static isString(value: any): any; + static isSymbol(value: any): any; + static isTypedArray(value: any): any; + static isUndefined(value: any): any; + static isWeakMap(value: any): any; + static isWeakSet(value: any): any; + static iteratee(func: any): any; + static join(array: any, separator: any): any; + static kebabCase(string: any): any; + static keyBy(collection: any, iteratee: any): any; + static keys(object: any): any; + static keysIn(object: any): any; + static last(array: any): any; + static lastIndexOf(array: any, value: any, fromIndex: any): any; + static lowerCase(string: any): any; + static lowerFirst(string: any): any; + static lt(value: any, other: any): any; + static lte(value: any, other: any): any; + static map(collection: any, iteratee: any): any; + static mapKeys(object: any, iteratee: any): any; + static mapValues(object: any, iteratee: any): any; + static matches(source: any): any; + static matchesProperty(path: any, srcValue: any): any; + static max(array: any): any; + static maxBy(array: any, iteratee: any): any; + static mean(array: any): any; + static meanBy(array: any, iteratee: any): any; + static merge(...args: any[]): any; + static mergeWith(...args: any[]): any; + static method(...args: any[]): any; + static methodOf(...args: any[]): any; + static min(array: any): any; + static minBy(array: any, iteratee: any): any; + static mixin(object: any, source: any, options: any): any; + static multiply(value: any, other: any): any; + static negate(predicate: any): any; + static noConflict(): any; + static noop(): void; + static now(): any; + static nth(array: any, n: any): any; + static nthArg(n: any): any; + static omit(...args: any[]): any; + static omitBy(object: any, predicate: any): any; + static once(func: any): any; + static orderBy(collection: any, iteratees: any, orders: any, guard: any): any; + static over(...args: any[]): any; + static overArgs(...args: any[]): any; + static overEvery(...args: any[]): any; + static overSome(...args: any[]): any; + static pad(string: any, length: any, chars: any): any; + static padEnd(string: any, length: any, chars: any): any; + static padStart(string: any, length: any, chars: any): any; + static parseInt(string: any, radix: any, guard: any): any; + static partition(collection: any, iteratee: any): any; + static pick(...args: any[]): any; + static pickBy(object: any, predicate: any): any; + static property(path: any): any; + static propertyOf(object: any): any; + static pull(...args: any[]): any; + static pullAll(array: any, values: any): any; + static pullAllBy(array: any, values: any, iteratee: any): any; + static pullAllWith(array: any, values: any, comparator: any): any; + static pullAt(...args: any[]): any; + static random(lower: any, upper: any, floating: any): any; + static range(start: any, end: any, step: any): any; + static rangeRight(start: any, end: any, step: any): any; + static rearg(...args: any[]): any; + static reduce(collection: any, iteratee: any, accumulator: any, ...args: any[]): any; + static reduceRight(collection: any, iteratee: any, accumulator: any, ...args: any[]): any; + static reject(collection: any, predicate: any): any; + static remove(array: any, predicate: any): any; + static repeat(string: any, n: any, guard: any): any; + static replace(...args: any[]): any; + static rest(func: any, start: any): any; + static result(object: any, path: any, defaultValue: any): any; + static reverse(array: any): any; + static round(number: any, precision: any): any; + static runInContext(context: any): any; + static sample(collection: any): any; + static sampleSize(collection: any, n: any, guard: any): any; + static set(object: any, path: any, value: any): any; + static setWith(object: any, path: any, value: any, customizer: any): any; + static shuffle(collection: any): any; + static size(collection: any): any; + static slice(array: any, start: any, end: any): any; + static snakeCase(string: any): any; + static some(collection: any, predicate: any, guard: any): any; + static sortBy(...args: any[]): any; + static sortedIndex(array: any, value: any): any; + static sortedIndexBy(array: any, value: any, iteratee: any): any; + static sortedIndexOf(array: any, value: any): any; + static sortedLastIndex(array: any, value: any): any; + static sortedLastIndexBy(array: any, value: any, iteratee: any): any; + static sortedLastIndexOf(array: any, value: any): any; + static sortedUniq(array: any): any; + static sortedUniqBy(array: any, iteratee: any): any; + static split(string: any, separator: any, limit: any): any; + static spread(func: any, start: any): any; + static startCase(string: any): any; + static startsWith(string: any, target: any, position: any): any; + static stubArray(): any; + static stubFalse(): any; + static stubObject(): any; + static stubString(): any; + static stubTrue(): any; + static subtract(value: any, other: any): any; + static sum(array: any): any; + static sumBy(array: any, iteratee: any): any; + static tail(array: any): any; + static take(array: any, n: any, guard: any): any; + static takeRight(array: any, n: any, guard: any): any; + static takeRightWhile(array: any, predicate: any): any; + static takeWhile(array: any, predicate: any): any; + static tap(value: any, interceptor: any): any; + static template(string: any, options: any, guard: any): any; + static templateSettings: { + escape: RegExp; + evaluate: RegExp; + imports: {}; + interpolate: RegExp; + variable: string; + }; + static throttle(func: any, wait: any, options: any): any; + static thru(value: any, interceptor: any): any; + static times(n: any, iteratee: any): any; + static toArray(value: any): any; + static toFinite(value: any): any; + static toInteger(value: any): any; + static toLength(value: any): any; + static toLower(value: any): any; + static toNumber(value: any): any; + static toPairs(object: any): any; + static toPairsIn(object: any): any; + static toPath(value: any): any; + static toPlainObject(value: any): any; + static toSafeInteger(value: any): any; + static toString(value: any): any; + static toUpper(value: any): any; + static transform(object: any, iteratee: any, accumulator: any): any; + static trim(string: any, chars: any, guard: any): any; + static trimEnd(string: any, chars: any, guard: any): any; + static trimStart(string: any, chars: any, guard: any): any; + static truncate(string: any, options: any): any; + static unary(func: any): any; + static unescape(string: any): any; + static union(...args: any[]): any; + static unionBy(...args: any[]): any; + static unionWith(...args: any[]): any; + static uniq(array: any): any; + static uniqBy(array: any, iteratee: any): any; + static uniqWith(array: any, comparator: any): any; + static uniqueId(prefix: any): any; + static unset(object: any, path: any): any; + static unzip(array: any): any; + static unzipWith(array: any, iteratee: any): any; + static update(object: any, path: any, updater: any): any; + static updateWith(object: any, path: any, updater: any, customizer: any): any; + static upperCase(string: any): any; + static upperFirst(string: any): any; + static values(object: any): any; + static valuesIn(object: any): any; + static without(...args: any[]): any; + static words(string: any, pattern: any, guard: any): any; + static wrap(value: any, wrapper: any): any; + static xor(...args: any[]): any; + static xorBy(...args: any[]): any; + static xorWith(...args: any[]): any; + static zip(...args: any[]): any; + static zipObject(props: any, values: any): any; + static zipObjectDeep(props: any, values: any): any; + static zipWith(...args: any[]): any; + constructor(value: any); add(...args: any[]): any; after(...args: any[]): any; ary(...args: any[]): any; @@ -8,7 +314,7 @@ declare class lodash { assignIn(...args: any[]): any; assignInWith(...args: any[]): any; assignWith(...args: any[]): any; - at(paths: any): any; + at(...args: any[]): any; attempt(...args: any[]): any; before(...args: any[]): any; bind(...args: any[]): any; @@ -280,7 +586,6 @@ declare class lodash { toPath(...args: any[]): any; toPlainObject(...args: any[]): any; toSafeInteger(...args: any[]): any; - toString(...args: any[]): any; toUpper(...args: any[]): any; transform(...args: any[]): any; trim(...args: any[]): any; @@ -318,496 +623,46 @@ declare class lodash { zipObject(...args: any[]): any; zipObjectDeep(...args: any[]): any; zipWith(...args: any[]): any; - static VERSION: string; - static add(value: any, other: any): any; - static after(n: any, func: any, ...args: any[]): any; - static ary(func: any, n: any, guard: any): any; - static assign(object: any, sources: any): any; - static assignIn(object: any, sources: any): any; - static assignInWith(object: any, sources: any): any; - static assignWith(object: any, sources: any): any; - static at(object: any, paths: any): any; - static attempt(func: any, args: any): any; - static before(n: any, func: any, ...args: any[]): any; - static bind(func: any, thisArg: any, partials: any): any; - static bindAll(object: any, methodNames: any): any; - static bindKey(object: any, key: any, partials: any): any; - static camelCase(string: any): any; - static capitalize(string: any): any; - static castArray(...args: any[]): any; - static ceil(number: any, precision: any): any; - static chain(value: any): any; - static chunk(array: any, size: any, guard: any): any; - static clamp(number: any, lower: any, upper: any): any; - static clone(value: any): any; - static cloneDeep(value: any): any; - static cloneDeepWith(value: any, customizer: any): any; - static cloneWith(value: any, customizer: any): any; - static compact(array: any): any; - static concat(...args: any[]): any; - static cond(pairs: any): any; - static conforms(source: any): any; - static conformsTo(object: any, source: any): any; - static constant(value: any): any; - static countBy(collection: any, iteratee: any): any; - static create(prototype: any, properties: any): any; - static curry(func: any, arity: any, guard: any): any; - static curryRight(func: any, arity: any, guard: any): any; - static debounce(func: any, wait: any, options: any, ...args: any[]): any; - static deburr(string: any): any; - static defaultTo(value: any, defaultValue: any): any; - static defaults(args: any): any; - static defaultsDeep(args: any): any; - static defer(func: any, args: any): any; - static delay(func: any, wait: any, args: any): any; - static difference(array: any, values: any): any; - static differenceBy(array: any, values: any): any; - static differenceWith(array: any, values: any): any; - static divide(value: any, other: any): any; - static drop(array: any, n: any, guard: any): any; - static dropRight(array: any, n: any, guard: any): any; - static dropRightWhile(array: any, predicate: any): any; - static dropWhile(array: any, predicate: any): any; - static each(collection: any, iteratee: any): any; - static eachRight(collection: any, iteratee: any): any; - static endsWith(string: any, target: any, position: any): any; - static entries(object: any): any; - static entriesIn(object: any): any; - static eq(value: any, other: any): any; - static escape(string: any): any; - static escapeRegExp(string: any): any; - static every(collection: any, predicate: any, guard: any): any; - static extend(object: any, sources: any): any; - static extendWith(object: any, sources: any): any; - static fill(array: any, value: any, start: any, end: any): any; - static filter(collection: any, predicate: any): any; - static find(collection: any, predicate: any, fromIndex: any): any; - static findIndex(array: any, predicate: any, fromIndex: any): any; - static findKey(object: any, predicate: any): any; - static findLast(collection: any, predicate: any, fromIndex: any): any; - static findLastIndex(array: any, predicate: any, fromIndex: any): any; - static findLastKey(object: any, predicate: any): any; - static first(array: any): any; - static flatMap(collection: any, iteratee: any): any; - static flatMapDeep(collection: any, iteratee: any): any; - static flatMapDepth(collection: any, iteratee: any, depth: any): any; - static flatten(array: any): any; - static flattenDeep(array: any): any; - static flattenDepth(array: any, depth: any): any; - static flip(func: any): any; - static floor(number: any, precision: any): any; - static flow(funcs: any, ...args: any[]): any; - static flowRight(funcs: any, ...args: any[]): any; - static forEach(collection: any, iteratee: any): any; - static forEachRight(collection: any, iteratee: any): any; - static forIn(object: any, iteratee: any): any; - static forInRight(object: any, iteratee: any): any; - static forOwn(object: any, iteratee: any): any; - static forOwnRight(object: any, iteratee: any): any; - static fromPairs(pairs: any): any; - static functions(object: any): any; - static functionsIn(object: any): any; - static get(object: any, path: any, defaultValue: any): any; - static groupBy(collection: any, iteratee: any): any; - static gt(value: any, other: any): any; - static gte(value: any, other: any): any; - static has(object: any, path: any): any; - static hasIn(object: any, path: any): any; - static head(array: any): any; - static identity(value: any): any; - static inRange(number: any, start: any, end: any): any; - static includes(collection: any, value: any, fromIndex: any, guard: any): any; - static indexOf(array: any, value: any, fromIndex: any): any; - static initial(array: any): any; - static intersection(arrays: any): any; - static intersectionBy(arrays: any): any; - static intersectionWith(arrays: any): any; - static invert(object: any, iteratee: any): any; - static invertBy(object: any, iteratee: any): any; - static invoke(object: any, path: any, args: any): any; - static invokeMap(collection: any, path: any, args: any): any; - static isArguments(value: any): any; - static isArray(p0: any): any; - static isArrayBuffer(value: any): any; - static isArrayLike(value: any): any; - static isArrayLikeObject(value: any): any; - static isBoolean(value: any): any; - static isBuffer(b: any): any; - static isDate(value: any): any; - static isElement(value: any): any; - static isEmpty(value: any): any; - static isEqual(value: any, other: any): any; - static isEqualWith(value: any, other: any, customizer: any): any; - static isError(value: any): any; - static isFinite(value: any): any; - static isFunction(value: any): any; - static isInteger(value: any): any; - static isLength(value: any): any; - static isMap(value: any): any; - static isMatch(object: any, source: any): any; - static isMatchWith(object: any, source: any, customizer: any): any; - static isNaN(value: any): any; - static isNative(value: any): any; - static isNil(value: any): any; - static isNull(value: any): any; - static isNumber(value: any): any; - static isObject(value: any): any; - static isObjectLike(value: any): any; - static isPlainObject(value: any): any; - static isRegExp(value: any): any; - static isSafeInteger(value: any): any; - static isSet(value: any): any; - static isString(value: any): any; - static isSymbol(value: any): any; - static isTypedArray(value: any): any; - static isUndefined(value: any): any; - static isWeakMap(value: any): any; - static isWeakSet(value: any): any; - static iteratee(func: any): any; - static join(array: any, separator: any): any; - static kebabCase(string: any): any; - static keyBy(collection: any, iteratee: any): any; - static keys(object: any): any; - static keysIn(object: any): any; - static last(array: any): any; - static lastIndexOf(array: any, value: any, fromIndex: any): any; - static lowerCase(string: any): any; - static lowerFirst(string: any): any; - static lt(value: any, other: any): any; - static lte(value: any, other: any): any; - static map(collection: any, iteratee: any): any; - static mapKeys(object: any, iteratee: any): any; - static mapValues(object: any, iteratee: any): any; - static matches(source: any): any; - static matchesProperty(path: any, srcValue: any): any; - static max(array: any): any; - static maxBy(array: any, iteratee: any): any; - static mean(array: any): any; - static meanBy(array: any, iteratee: any): any; - static memoize(func: any, resolver: any, ...args: any[]): any; - static merge(object: any, sources: any): any; - static mergeWith(object: any, sources: any): any; - static method(path: any, args: any): any; - static methodOf(object: any, args: any): any; - static min(array: any): any; - static minBy(array: any, iteratee: any): any; - static mixin(object: any, source: any, options: any, ...args: any[]): any; - static multiply(value: any, other: any): any; - static negate(predicate: any, ...args: any[]): any; - static noConflict(): any; - static noop(): void; - static now(): any; - static nth(array: any, n: any): any; - static nthArg(n: any): any; - static omit(object: any, paths: any): any; - static omitBy(object: any, predicate: any): any; - static once(func: any): any; - static orderBy(collection: any, iteratees: any, orders: any, guard: any): any; - static over(iteratees: any): any; - static overArgs(func: any, transforms: any): any; - static overEvery(iteratees: any): any; - static overSome(iteratees: any): any; - static pad(string: any, length: any, chars: any): any; - static padEnd(string: any, length: any, chars: any): any; - static padStart(string: any, length: any, chars: any): any; - static parseInt(string: any, radix: any, guard: any): any; - static partial(func: any, partials: any): any; - static partialRight(func: any, partials: any): any; - static partition(collection: any, iteratee: any): any; - static pick(object: any, paths: any): any; - static pickBy(object: any, predicate: any): any; - static property(path: any): any; - static propertyOf(object: any): any; - static pull(array: any, values: any): any; - static pullAll(array: any, values: any): any; - static pullAllBy(array: any, values: any, iteratee: any): any; - static pullAllWith(array: any, values: any, comparator: any): any; - static pullAt(array: any, indexes: any): any; - static random(lower: any, upper: any, floating: any): any; - static range(start: any, end: any, step: any): any; - static rangeRight(start: any, end: any, step: any): any; - static rearg(func: any, indexes: any): any; - static reduce(collection: any, iteratee: any, accumulator: any, ...args: any[]): any; - static reduceRight(collection: any, iteratee: any, accumulator: any, ...args: any[]): any; - static reject(collection: any, predicate: any): any; - static remove(array: any, predicate: any): any; - static repeat(string: any, n: any, guard: any): any; - static replace(...args: any[]): any; - static rest(func: any, start: any): any; - static result(object: any, path: any, defaultValue: any): any; - static reverse(array: any): any; - static round(number: any, precision: any): any; - static runInContext(context: any, ...args: any[]): any; - static sample(collection: any): any; - static sampleSize(collection: any, n: any, guard: any): any; - static set(object: any, path: any, value: any): any; - static setWith(object: any, path: any, value: any, customizer: any): any; - static shuffle(collection: any): any; - static size(collection: any): any; - static slice(array: any, start: any, end: any): any; - static snakeCase(string: any): any; - static some(collection: any, predicate: any, guard: any): any; - static sortBy(collection: any, iteratees: any): any; - static sortedIndex(array: any, value: any): any; - static sortedIndexBy(array: any, value: any, iteratee: any): any; - static sortedIndexOf(array: any, value: any): any; - static sortedLastIndex(array: any, value: any): any; - static sortedLastIndexBy(array: any, value: any, iteratee: any): any; - static sortedLastIndexOf(array: any, value: any): any; - static sortedUniq(array: any): any; - static sortedUniqBy(array: any, iteratee: any): any; - static split(string: any, separator: any, limit: any): any; - static spread(func: any, start: any): any; - static startCase(string: any): any; - static startsWith(string: any, target: any, position: any): any; - static stubArray(): any; - static stubFalse(): any; - static stubObject(): any; - static stubString(): any; - static stubTrue(): any; - static subtract(value: any, other: any): any; - static sum(array: any): any; - static sumBy(array: any, iteratee: any): any; - static tail(array: any): any; - static take(array: any, n: any, guard: any): any; - static takeRight(array: any, n: any, guard: any): any; - static takeRightWhile(array: any, predicate: any): any; - static takeWhile(array: any, predicate: any): any; - static tap(value: any, interceptor: any): any; - static template(string: any, options: any, guard: any): any; - static templateSettings: { - escape: RegExp; - evaluate: RegExp; - imports: { - }; - interpolate: RegExp; - variable: string; - }; - static throttle(func: any, wait: any, options: any): any; - static thru(value: any, interceptor: any): any; - static times(n: any, iteratee: any): any; - static toArray(value: any): any; - static toFinite(value: any): any; - static toInteger(value: any): any; - static toLength(value: any): any; - static toLower(value: any): any; - static toNumber(value: any): any; - static toPairs(object: any): any; - static toPairsIn(object: any): any; - static toPath(value: any): any; - static toPlainObject(value: any): any; - static toSafeInteger(value: any): any; - static toString(value: any): any; - static toUpper(value: any): any; - static transform(object: any, iteratee: any, accumulator: any): any; - static trim(string: any, chars: any, guard: any): any; - static trimEnd(string: any, chars: any, guard: any): any; - static trimStart(string: any, chars: any, guard: any): any; - static truncate(string: any, options: any): any; - static unary(func: any): any; - static unescape(string: any): any; - static union(arrays: any): any; - static unionBy(arrays: any): any; - static unionWith(arrays: any): any; - static uniq(array: any): any; - static uniqBy(array: any, iteratee: any): any; - static uniqWith(array: any, comparator: any): any; - static uniqueId(prefix: any): any; - static unset(object: any, path: any): any; - static unzip(array: any): any; - static unzipWith(array: any, iteratee: any): any; - static update(object: any, path: any, updater: any): any; - static updateWith(object: any, path: any, updater: any, customizer: any): any; - static upperCase(string: any): any; - static upperFirst(string: any): any; - static values(object: any): any; - static valuesIn(object: any): any; - static without(array: any, values: any): any; - static words(string: any, pattern: any, guard: any): any; - static wrap(value: any, wrapper: any): any; - static xor(arrays: any): any; - static xorBy(arrays: any): any; - static xorWith(arrays: any): any; - static zip(array: any): any; - static zipObject(props: any, values: any): any; - static zipObjectDeep(props: any, values: any): any; - static zipWith(arrays: any): any; } declare namespace lodash { - namespace assign { - function toString(): any; - } - namespace assignIn { - function toString(): any; - } - namespace assignInWith { - function toString(): any; - } - namespace assignWith { - function toString(): any; - } - namespace at { - function toString(): any; - } - namespace attempt { - function toString(): any; - } + function bind(...args: any[]): any; namespace bind { // Circular reference from lodash.bind const placeholder: any; - function toString(): any; - } - namespace bindAll { - function toString(): any; } + function bindKey(...args: any[]): any; namespace bindKey { // Circular reference from lodash.bindKey const placeholder: any; - function toString(): any; } + function curry(func: any, arity: any, guard: any): any; namespace curry { // Circular reference from lodash.curry const placeholder: any; } + function curryRight(func: any, arity: any, guard: any): any; namespace curryRight { // Circular reference from lodash.curryRight const placeholder: any; } - namespace defaults { - function toString(): any; - } - namespace defaultsDeep { - function toString(): any; - } - namespace defer { - function toString(): any; - } - namespace delay { - function toString(): any; - } - namespace difference { - function toString(): any; - } - namespace differenceBy { - function toString(): any; - } - namespace differenceWith { - function toString(): any; - } - namespace extend { - function toString(): any; - } - namespace extendWith { - function toString(): any; - } - namespace flow { - function toString(): any; - } - namespace flowRight { - function toString(): any; - } - namespace intersection { - function toString(): any; - } - namespace intersectionBy { - function toString(): any; - } - namespace intersectionWith { - function toString(): any; - } - namespace invoke { - function toString(): any; - } - namespace invokeMap { - function toString(): any; - } + function memoize(func: any, resolver: any): any; namespace memoize { class Cache { constructor(entries: any); clear(): void; - delete(key: any): any; get(key: any): any; has(key: any): any; set(key: any, value: any): any; } } - namespace merge { - function toString(): any; - } - namespace mergeWith { - function toString(): any; - } - namespace method { - function toString(): any; - } - namespace methodOf { - function toString(): any; - } - namespace omit { - function toString(): any; - } - namespace over { - function toString(): any; - } - namespace overArgs { - function toString(): any; - } - namespace overEvery { - function toString(): any; - } - namespace overSome { - function toString(): any; - } + function partial(...args: any[]): any; namespace partial { // Circular reference from lodash.partial const placeholder: any; - function toString(): any; } + function partialRight(...args: any[]): any; namespace partialRight { // Circular reference from lodash.partialRight const placeholder: any; - function toString(): any; - } - namespace pick { - function toString(): any; - } - namespace pull { - function toString(): any; - } - namespace pullAt { - function toString(): any; - } - namespace rearg { - function toString(): any; - } - namespace sortBy { - function toString(): any; - } - namespace union { - function toString(): any; - } - namespace unionBy { - function toString(): any; - } - namespace unionWith { - function toString(): any; - } - namespace without { - function toString(): any; - } - namespace xor { - function toString(): any; - } - namespace xorBy { - function toString(): any; - } - namespace xorWith { - function toString(): any; - } - namespace zip { - function toString(): any; - } - namespace zipWith { - function toString(): any; } } diff --git a/baselines/module-path.d.ts b/baselines/module-path.d.ts index ef133e4..5e32c30 100644 --- a/baselines/module-path.d.ts +++ b/baselines/module-path.d.ts @@ -1,6 +1,5 @@ -export const delimiter: string; -export const sep: string; export function basename(path: any, ext: any): any; +export const delimiter: string; export function dirname(path: any): any; export function extname(path: any): any; export function format(pathObject: any): any; @@ -8,350 +7,15 @@ export function isAbsolute(path: any): any; export function join(...args: any[]): any; export function normalize(path: any): any; export function parse(path: any): any; +// Circular reference from path +export const posix: any; export function relative(from: any, to: any): any; export function resolve(...args: any[]): any; -export namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.posix.posix.posix.posix - const basename: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const delimiter: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const dirname: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const extname: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const format: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const join: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const normalize: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const parse: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const posix: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const relative: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const resolve: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const sep: any; - // Too-deep object hierarchy from path.posix.posix.posix.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const basename: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const delimiter: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const dirname: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const extname: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const format: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const join: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const normalize: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const parse: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const posix: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const relative: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const resolve: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const sep: any; - // Too-deep object hierarchy from path.posix.posix.posix.win32 - const win32: any; - } - } - namespace win32 { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.posix.posix.win32.posix - const basename: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const delimiter: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const dirname: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const extname: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const format: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const join: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const normalize: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const parse: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const posix: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const relative: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const resolve: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const sep: any; - // Too-deep object hierarchy from path.posix.posix.win32.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const basename: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const delimiter: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const dirname: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const extname: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const format: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const join: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const normalize: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const parse: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const posix: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const relative: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const resolve: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const sep: any; - // Too-deep object hierarchy from path.posix.posix.win32.win32 - const win32: any; - } - } - } - namespace win32 { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.posix.win32.posix.posix - const basename: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const delimiter: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const dirname: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const extname: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const format: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const join: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const normalize: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const parse: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const posix: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const relative: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const resolve: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const sep: any; - // Too-deep object hierarchy from path.posix.win32.posix.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const basename: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const delimiter: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const dirname: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const extname: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const format: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const join: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const normalize: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const parse: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const posix: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const relative: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const resolve: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const sep: any; - // Too-deep object hierarchy from path.posix.win32.posix.win32 - const win32: any; - } - } - namespace win32 { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.posix.win32.win32.posix - const basename: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const delimiter: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const dirname: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const extname: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const format: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const join: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const normalize: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const parse: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const posix: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const relative: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const resolve: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const sep: any; - // Too-deep object hierarchy from path.posix.win32.win32.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const basename: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const delimiter: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const dirname: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const extname: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const format: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const join: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const normalize: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const parse: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const posix: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const relative: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const resolve: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const sep: any; - // Too-deep object hierarchy from path.posix.win32.win32.win32 - const win32: any; - } - } - } -} +export const sep: string; +export function toNamespacedPath(path: any): any; export namespace win32 { - const delimiter: string; - const sep: string; function basename(path: any, ext: any): any; + const delimiter: string; function dirname(path: any): any; function extname(path: any): any; function format(pathObject: any): any; @@ -359,330 +23,12 @@ export namespace win32 { function join(...args: any[]): any; function normalize(path: any): any; function parse(path: any): any; + // Circular reference from path.win32 + const posix: any; function relative(from: any, to: any): any; function resolve(...args: any[]): any; - namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.win32.posix.posix.posix - const basename: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const delimiter: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const dirname: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const extname: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const format: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const join: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const normalize: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const parse: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const posix: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const relative: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const resolve: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const sep: any; - // Too-deep object hierarchy from path.win32.posix.posix.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const basename: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const delimiter: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const dirname: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const extname: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const format: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const join: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const normalize: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const parse: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const posix: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const relative: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const resolve: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const sep: any; - // Too-deep object hierarchy from path.win32.posix.posix.win32 - const win32: any; - } - } - namespace win32 { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.win32.posix.win32.posix - const basename: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const delimiter: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const dirname: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const extname: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const format: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const join: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const normalize: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const parse: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const posix: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const relative: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const resolve: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const sep: any; - // Too-deep object hierarchy from path.win32.posix.win32.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const basename: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const delimiter: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const dirname: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const extname: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const format: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const join: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const normalize: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const parse: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const posix: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const relative: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const resolve: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const sep: any; - // Too-deep object hierarchy from path.win32.posix.win32.win32 - const win32: any; - } - } - } - namespace win32 { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.win32.win32.posix.posix - const basename: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const delimiter: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const dirname: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const extname: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const format: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const join: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const normalize: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const parse: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const posix: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const relative: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const resolve: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const sep: any; - // Too-deep object hierarchy from path.win32.win32.posix.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const basename: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const delimiter: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const dirname: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const extname: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const format: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const join: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const normalize: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const parse: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const posix: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const relative: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const resolve: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const sep: any; - // Too-deep object hierarchy from path.win32.win32.posix.win32 - const win32: any; - } - } - namespace win32 { - const delimiter: string; - const sep: string; - function basename(path: any, ext: any): any; - function dirname(path: any): any; - function extname(path: any): any; - function format(pathObject: any): any; - function isAbsolute(path: any): any; - function join(...args: any[]): any; - function normalize(path: any): any; - function parse(path: any): any; - function relative(from: any, to: any): any; - function resolve(...args: any[]): any; - namespace posix { - // Too-deep object hierarchy from path.win32.win32.win32.posix - const basename: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const delimiter: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const dirname: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const extname: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const format: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const join: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const normalize: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const parse: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const posix: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const relative: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const resolve: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const sep: any; - // Too-deep object hierarchy from path.win32.win32.win32.posix - const win32: any; - } - namespace win32 { - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const basename: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const delimiter: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const dirname: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const extname: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const format: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const isAbsolute: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const join: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const normalize: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const parse: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const posix: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const relative: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const resolve: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const sep: any; - // Too-deep object hierarchy from path.win32.win32.win32.win32 - const win32: any; - } - } - } + const sep: string; + function toNamespacedPath(path: any): any; + // Circular reference from path.win32 + const win32: any; } diff --git a/baselines/module-yargs.d.ts b/baselines/module-yargs.d.ts index dc3b999..9cc574d 100644 --- a/baselines/module-yargs.d.ts +++ b/baselines/module-yargs.d.ts @@ -2,13 +2,11 @@ export = yargs; declare function yargs(processArgs: any, cwd: any): any; declare namespace yargs { const $0: string; - const argv: { - $0: string; - }; - const parsed: boolean; function addHelpOpt(p0: any, p1: any): any; function alias(p0: any, p1: any): any; + const argv: any; function array(p0: any): any; + function boolean(p0: any): any; function check(p0: any): any; function choices(p0: any, p1: any): any; function command(p0: any, p1: any, p2: any, p3: any): any; @@ -48,6 +46,7 @@ declare namespace yargs { function option(p0: any, p1: any): any; function options(p0: any, p1: any): any; function parse(p0: any, p1: any): any; + const parsed: boolean; function pkgConf(p0: any, p1: any): any; function require(p0: any, p1: any, p2: any): any; function required(p0: any, p1: any, p2: any): any; diff --git a/lib/index.ts b/lib/index.ts index 5e22cf3..49837d9 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,417 +1,9 @@ -import * as dom from 'dts-dom'; -import { create, reservedWords } from 'dts-dom'; import * as ts from 'typescript'; -const enum ValueTypes { - None = 0, - Class = 1 << 0, - Function = 1 << 1, - Object = 1 << 2, - Primitive = 1 << 3, - NullOrUndefined = 1 << 4, - Unknown = 1 << 5, -} - -const builtins: { [name: string]: (new (...args: any[]) => any) | undefined } = { - Date, - RegExp, - Map: (typeof Map !== 'undefined') ? Map : undefined, - HTMLElement: (typeof HTMLElement !== 'undefined') ? HTMLElement : undefined, -}; - -function forceAsIdentifier(s: string): string { - // TODO: Make this more comprehensive - let ret = s.replace(/-/g, '_'); - if (ret.indexOf('@') === 0 && ret.indexOf('/') !== -1) { - // we have a scoped module, e.g. @bla/foo - // which should be converted to bla__foo - ret = ret.substr(1).replace('/', '__'); - } - return ret; -} - -function getValueTypes(value: any): ValueTypes { - if (typeof value === 'object') { - // Objects can't be callable, so no need to check for class / function - return ValueTypes.Object; - } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { - return ValueTypes.Primitive; - } else if (value === null || value === undefined) { - return ValueTypes.NullOrUndefined; - } else if (typeof value === 'function') { - if (isClasslike(value)) { - return ValueTypes.Class | (hasCloduleProperties(value) ? ValueTypes.Object : ValueTypes.None); - } else { - return ValueTypes.Function | (hasFunduleProperties(value) ? ValueTypes.Object : ValueTypes.None); - } - } else { - return ValueTypes.Unknown; - } -} - -// A class has clodule properties if it has any classes. Anything else can be written with 'static' -function hasCloduleProperties(c: any): boolean { - return getKeysOfObject(c).some(k => isClasslike(c[k])); -} - -// A function has fundule properties if it has any own properties not belonging to Function.prototype -function hasFunduleProperties(fn: any): boolean { - return getKeysOfObject(fn).some(k => ( Function)[k] === undefined); -} - -export function generateModuleDeclarationFile(nameHint: string, root: any) { - const localName = forceAsIdentifier(nameHint); - const decls = getTopLevelDeclarations(localName, root); - // If we get back just a namespace, we can avoid writing an export= - if (decls.length === 1 && decls[0].kind === 'namespace') { - // Hoist out all the declarations and export them - const members = (decls[0] as dom.NamespaceDeclaration).members; - for (const m of members) m.flags = m.flags! | dom.DeclarationFlags.Export; - return members.map(m => dom.emit(m)).join(''); - } else { - // Going to have to write an export= - const result: string[] = decls.map(d => dom.emit(d)); - result.unshift(dom.emit(dom.create.exportEquals(localName))); - return result.join(''); - } +export function generateModuleDeclarationFile(nameHint: string, root: any): string { + return ts.generateTypesForModule(nameHint, root, ts.getDefaultFormatCodeSettings("\r\n")); } export function generateIdentifierDeclarationFile(name: string, value: any): string { - const result = getTopLevelDeclarations(name, value); - return result.map(d => dom.emit(d)).join('\r\n'); -} - -const walkStack = new Set(); - -const reservedFunctionProperties = Object.getOwnPropertyNames(() => {}); -function getKeysOfObject(obj: object) { - let keys: string[] = []; - let chain: {} = obj; - do { - if (chain == null) break; - keys = keys.concat(Object.getOwnPropertyNames(chain)); - chain = Object.getPrototypeOf(chain); - } while (chain !== Object.prototype && chain !== Function.prototype); - keys = Array.from(new Set(keys)); - keys = keys.filter(s => isVisitableName(s)); - if (typeof obj === 'function') { - keys = keys.filter(k => reservedFunctionProperties.indexOf(k) < 0); - } - - keys.sort(); - return keys; -} - -function isVisitableName(s: string) { - return (s[0] !== '_') && (["caller", "arguments", "constructor", "super_"].indexOf(s) < 0); -} - -function isLegalIdentifier(s: string) { - if (s.length === 0) { - return false; - } - if (!ts.isIdentifierStart(s.charCodeAt(0), ts.ScriptTarget.Latest)) { - return false; - } - for (let i = 1; i < s.length; i++) { - if (!ts.isIdentifierPart(s.charCodeAt(i), ts.ScriptTarget.Latest)) { - return false; - } - } - return reservedWords.indexOf(s) < 0; -} - -function isClasslike(obj: { prototype: any }): boolean { - return !!(obj.prototype && Object.getOwnPropertyNames(obj.prototype).length > 1); -} - -const keyStack: string[] = []; -function getTopLevelDeclarations(name: string, obj: any): dom.NamespaceMember[] { - if (walkStack.has(obj) || keyStack.length > 4) { - // Circular or too-deep reference - const result = create.const(name, dom.type.any); - result.comment = (walkStack.has(obj) ? 'Circular reference' : 'Too-deep object hierarchy') + - ` from ${keyStack.join('.')}`; - return [result]; - } - - if (!isLegalIdentifier(name)) return []; - - walkStack.add(obj); - keyStack.push(name); - const res = getResult(); - keyStack.pop(); - walkStack.delete(obj); - return res; - - function getResult(): dom.NamespaceMember[] { - if (typeof obj === 'function') { - const funcType = getParameterListAndReturnType(obj, parseFunctionBody(obj)); - const ns = dom.create.namespace(name); - let primaryDecl: dom.NamespaceMember; - if (isClasslike(obj)) { - const cls = dom.create.class(name); - getClassInstanceMembers(obj).forEach(m => cls.members.push(m)); - getClassPrototypeMembers(obj).forEach(m => cls.members.push(m)); - cls.members.push(dom.create.constructor(funcType[0])); - cls.members.sort(declarationComparer); - primaryDecl = cls; - } else { - const parsedFunction = parseFunctionBody(obj); - const info = getParameterListAndReturnType(obj, parsedFunction); - primaryDecl = dom.create.function(name, info[0], info[1]); - } - - // Get clodule/fundule members - const keys = getKeysOfObject(obj); - for (const k of keys) { - getTopLevelDeclarations(k!, obj[k!]).forEach(p => { - if (primaryDecl.kind === "class") { - // Transform certain declarations into static members - switch (p.kind) { - case 'const': - primaryDecl.members.push(create.property(p.name, p.type, dom.DeclarationFlags.Static)); - break; - case 'function': - primaryDecl.members.push(create.method(p.name, p.parameters, p.returnType, dom.DeclarationFlags.Static)); - break; - default: - ns.members.push(p); - break; - } - } else { - ns.members.push(p); - } - }); - ns.members.sort(declarationComparer); - } - - return ns.members.length > 0 ? [primaryDecl, ns] : [primaryDecl]; - } else if (typeof obj === 'object') { - // If we can immediately resolve this to a simple declaration, just do so - const simpleType = getTypeOfValue(obj); - if (typeof simpleType === 'string' || simpleType.kind === 'name' || simpleType.kind === 'array') { - const result = dom.create.const(name, simpleType); - if (simpleType === 'string') { - result.comment = `Value of string: "${simpleType.substr(0, 100)}${simpleType.length > 100 ? '...' : ''}"`; - } - return [result]; - } - - // If anything in here is classlike or functionlike, write it as a namespace. - // Otherwise, write as a 'const' - const keys = getKeysOfObject(obj); - let constituentTypes = ValueTypes.None; - for (const k of keys) { - constituentTypes = constituentTypes | getValueTypes(( obj)[k!]); - } - if (constituentTypes & (ValueTypes.Class | ValueTypes.Function)) { - const ns = dom.create.namespace(name); - for (const k of keys) { - const decls = getTopLevelDeclarations(k!, ( obj)[k!]); - decls.forEach(d => ns.members.push(d)); - } - ns.members.sort(declarationComparer); - return [ns]; - } else { - return [dom.create.const(name, simpleType)]; - } - } else if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') { - return [create.const(name, (typeof obj))]; - } else { - return [create.const(name, dom.type.any)]; - } - } -} - -function getTypeOfValue(value: any): dom.Type { - for (const k in builtins) { - if (builtins[k] && value instanceof builtins[k]!) { - return create.namedTypeReference(k); - } - } - - if (Array.isArray(value)) { - if (value.length > 0) { - return create.array(getTypeOfValue(value[0])); - } else { - return create.array(dom.type.any); - } - } - - const type = typeof value; - switch (type) { - case 'string': - case 'number': - case 'boolean': - return type; - case 'undefined': - return dom.type.any; - case 'object': - if (value === null) { - return dom.type.any; - } else { - walkStack.add(value); - const members = getPropertyDeclarationsOfObject(value); - walkStack.delete(value); - members.sort(declarationComparer); - const objType = dom.create.objectType(members); - return objType; - } - default: - return dom.type.any; - } -} - -function getPropertyDeclarationsOfObject(obj: any): dom.ObjectTypeMember[] { - walkStack.add(obj); - const keys = getKeysOfObject(obj); - const result = keys.map(getProperty); - walkStack.delete(obj); - return result; - - function getProperty(k: string) { - if (walkStack.has(obj[k])) { - return create.property(k, dom.type.any); - } - return create.property(k, getTypeOfValue(obj[k])); - } -} - -function getClassPrototypeMembers(ctor: any): dom.ClassMember[] { - const names = Object.getOwnPropertyNames(ctor.prototype); - const members = names - .filter(n => !isNameToSkip(n)) - .map(name => - getPrototypeMember(name, Object.getOwnPropertyDescriptor(ctor.prototype, name).value)) - .filter(m => m !== undefined); - members.sort(); - return members; - - function getPrototypeMember(name: string, obj: any): dom.ClassMember | undefined { - // Skip non-function objects on the prototype (not sure what to do with these?) - if (typeof obj !== 'function') { - return undefined; - } - - const funcType = getParameterListAndReturnType(obj, parseFunctionBody(obj)); - const result = create.method(name, funcType[0], funcType[1]); - if (isNativeFunction(obj)) { - result.comment = 'Native method; no parameter or return type inference available'; - } - return result; - } - - function isNameToSkip(s: string) { - return (s === 'constructor') || (s[0] === '_'); - } -} - -// Parses assignments to 'this.x' in the constructor into class property declarations -function getClassInstanceMembers(ctor: any): dom.ClassMember[] { - if (isNativeFunction(ctor)) { - return []; - } - - const members: dom.ClassMember[] = []; - - function visit(node: ts.Node) { - switch (node.kind) { - case ts.SyntaxKind.BinaryExpression: - if ((node as ts.BinaryExpression).operatorToken.kind === ts.SyntaxKind.EqualsToken) { - const lhs = (node as ts.BinaryExpression).left; - if (lhs.kind === ts.SyntaxKind.PropertyAccessExpression) { - if ((lhs as ts.PropertyAccessExpression).expression.kind === ts.SyntaxKind.ThisKeyword) { - members.push( - create.property( - (lhs as ts.PropertyAccessExpression).name.getText(), - dom.type.any, - dom.DeclarationFlags.None)); - } - } - } - break; - } - ts.forEachChild(node, visit); - } - - return members; -} - -function declarationComparer(left: any, right: any) { - if (left.kind === right.kind) { - return left.name > right.name ? 1 : left.name < right.name ? -1 : 0; - } else { - return left.kind > right.kind ? 1 : left.kind < right.kind ? -1 : 0; - } -} - -function getParameterListAndReturnType(obj: Function, fn: ts.FunctionExpression): [dom.Parameter[], dom.Type] { - let usedArguments = false; - let hasReturn = false; - const funcStack: boolean[] = []; - - if (isNativeFunction(obj)) { - const args: dom.Parameter[] = []; - for (let i = 0; i < obj.length; i++) { - args.push(create.parameter(`p${i}`, dom.type.any)); - } - return [args, dom.type.any]; - } else { - ts.forEachChild(fn, visit); - - let params = [create.parameter('args', dom.type.array(dom.type.any), dom.ParameterFlags.Rest)]; - if (fn.parameters) { - params = fn.parameters.map(p => create.parameter(`${p.name.getText()}`, inferParameterType(fn, p))); - if (usedArguments) { - params.push(create.parameter('args', dom.type.array(dom.type.any), dom.ParameterFlags.Rest)); - } - } - return [params, hasReturn ? dom.type.any : dom.type.void]; - } - - function visit(node: ts.Node) { - switch (node.kind) { - case ts.SyntaxKind.Identifier: - if ((node as ts.Identifier).getText() === 'arguments') { - usedArguments = true; - } - break; - case ts.SyntaxKind.ReturnStatement: - const ret = node as ts.ReturnStatement; - if (funcStack.length === 0 && ret.expression && ret.expression.kind !== ts.SyntaxKind.VoidExpression) { - hasReturn = true; - } - } - switch (node.kind) { - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.FunctionDeclaration: - funcStack.push(true); - ts.forEachChild(node, visit); - funcStack.pop(); - - default: - ts.forEachChild(node, visit); - break; - } - } - -} - -function inferParameterType(_fn: ts.FunctionExpression, _param: ts.ParameterDeclaration): dom.Type { - // TODO: Inspect function body for clues - return dom.type.any; -} - -function parseFunctionBody(fn: any): ts.FunctionExpression { - const setup = `const myFn = ${fn.toString()};`; - const srcFile = ts.createSourceFile('test.ts', setup, ts.ScriptTarget.Latest, true); - const statement = srcFile.statements[0] as ts.VariableStatement; - const decl = statement.declarationList.declarations[0]; - const init = decl.initializer as ts.FunctionExpression; - return init; -} - -function isNativeFunction(fn: any) { - return fn.toString().indexOf('{ [native code] }') > 0; + return ts.generateTypesForGlobal(name, value, ts.getDefaultFormatCodeSettings("\r\n")); } diff --git a/lib/run.ts b/lib/run.ts index 6624dfd..d9e9e33 100644 --- a/lib/run.ts +++ b/lib/run.ts @@ -26,7 +26,7 @@ interface Options { version?: boolean; } -const args: Options = yargs +const args = yargs .alias('m', 'module') .alias('i', 'identifier') .alias('e', 'expression') @@ -37,7 +37,7 @@ const args: Options = yargs .alias('o', 'overwrite') .alias('t', 'template') .alias('v', 'version') - .argv; + .argv as unknown as Options; class ArgsError extends Error { constructor(public argsError: string) { diff --git a/package.json b/package.json index c38797b..bba0828 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "dts-gen": "bin/lib/run.js" }, "dependencies": { - "dts-dom": "latest", "parse-git-config": "^1.1.1", "typescript": "^2.2.0", "yargs": "^4.8.1" diff --git a/tests/test.ts b/tests/test.ts index 3d347b7..8c71a3b 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -41,7 +41,7 @@ function checkDeclarationBaseline(name: string, content: string) { const filename = path.join(__dirname, `../../baselines/${name}`); const existing = fs.existsSync(filename) ? fs.readFileSync(filename, 'utf-8') : ''; if (existing !== content) { - fs.writeFile(filename, content, 'utf-8'); + fs.writeFileSync(filename, content, 'utf-8'); throw new Error(`Baseline ${name} changed`); } }