From addbddf1399ae24832358dd7a0562a84eed935b7 Mon Sep 17 00:00:00 2001 From: nullishamy Date: Mon, 28 Aug 2023 15:54:38 +0100 Subject: [PATCH] feat: scaffold tsd tests --- jest.config.tsd.js | 8 ++ package-lock.json | 218 ++++++++++++++++++++++++++++-------- package.json | 5 +- src/builder/command.ts | 6 +- src/internal/types.ts | 3 - src/util/index.ts | 1 + src/util/types.ts | 3 + test/test-d/index.test-d.ts | 15 +++ test/test-d/util.ts | 0 tsconfig.json | 2 +- 10 files changed, 209 insertions(+), 52 deletions(-) create mode 100644 jest.config.tsd.js delete mode 100644 src/internal/types.ts create mode 100644 src/util/types.ts create mode 100644 test/test-d/index.test-d.ts create mode 100644 test/test-d/util.ts diff --git a/jest.config.tsd.js b/jest.config.tsd.js new file mode 100644 index 0000000..f7134fc --- /dev/null +++ b/jest.config.tsd.js @@ -0,0 +1,8 @@ +module.exports = { + displayName: { + color: 'blue', + name: 'types' + }, + runner: 'jest-runner-tsd', + testMatch: ['**/test/test-d/*.test-d.ts'] +} diff --git a/package-lock.json b/package-lock.json index 782c95b..14fc97d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "args.ts", - "version": "1.0.3", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "args.ts", - "version": "1.0.3", + "version": "1.1.0", "license": "OSL-3.0", "devDependencies": { + "@tsd/typescript": "^5.2.2", "@types/jest": "^29.0.3", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^5.37.0", @@ -22,6 +23,7 @@ "eslint-plugin-tsdoc": "^0.2.17", "husky": "^8.0.1", "jest": "^29.0.3", + "jest-runner-tsd": "^6.0.0", "lint-staged": "^13.0.3", "nodemon": "^2.0.20", "ts-cleaner": "^1.0.5", @@ -1011,12 +1013,12 @@ } }, "node_modules/@jest/schemas": { - "version": "29.0.0", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.0.0.tgz", - "integrity": "sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, "dependencies": { - "@sinclair/typebox": "^0.24.1" + "@sinclair/typebox": "^0.27.8" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -1093,12 +1095,12 @@ } }, "node_modules/@jest/types": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.0.3.tgz", - "integrity": "sha512-coBJmOQvurXjN1Hh5PzF7cmsod0zLIOXpP8KD161mqNlroMhLcwpODiEzi7ZsRl5Z/AIuxpeNm8DCl43F4kz8A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, "dependencies": { - "@jest/schemas": "^29.0.0", + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", @@ -1223,9 +1225,9 @@ } }, "node_modules/@sinclair/typebox": { - "version": "0.24.40", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.40.tgz", - "integrity": "sha512-Xint60L8rF0+nRy+6fCjW9jQMmu7fTpbwTBrXZiK6eq/RHDJS7LvWX/0oXC8O7fCePmrY/XdfaTv2HiUDeCq4g==", + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true }, "node_modules/@sinonjs/commons": { @@ -1246,6 +1248,15 @@ "@sinonjs/commons": "^1.7.0" } }, + "node_modules/@tsd/typescript": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@tsd/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-VtjHPAKJqLJoHHKBDNofzvQB2+ZVxjXU/Gw6INAS9aINLQYVsxfzrQ2s84huCeYWZRTtrr7R0J7XgpZHjNwBCw==", + "dev": true, + "engines": { + "node": ">=14.17" + } + }, "node_modules/@types/babel__core": { "version": "7.1.19", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz", @@ -2084,9 +2095,9 @@ ] }, "node_modules/chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { "ansi-styles": "^4.1.0", @@ -2363,6 +2374,47 @@ "safe-buffer": "~5.1.1" } }, + "node_modules/create-jest-runner": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/create-jest-runner/-/create-jest-runner-0.12.3.tgz", + "integrity": "sha512-xrGcSrr86F2YdbrOoAZIowSYMYBpxrOrqHEvJqIpG0vsuMVcq3+OKSe7JJR1SWJFLGiMhHInPyR48+rW9ZHq9Q==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "jest-worker": "^29.5.0", + "p-limit": "^3.1.0" + }, + "bin": { + "create-jest-runner": "generator/index.js" + }, + "peerDependencies": { + "@jest/test-result": "^28.0.0 || ^29.0.0", + "jest-runner": "^28.0.0 || ^29.0.0" + }, + "peerDependenciesMeta": { + "@jest/test-result": { + "optional": true + }, + "jest-runner": { + "optional": true + } + } + }, + "node_modules/create-jest-runner/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -4385,6 +4437,24 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-runner-tsd": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/jest-runner-tsd/-/jest-runner-tsd-6.0.0.tgz", + "integrity": "sha512-lSzRoVqc/AwahlKFamdwO/R63Vze/xpCnab+FsNni8zmxyBt3e3py51mFE2UQBh2gSvEYwudOSHgX+xtmLynKw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.15.8", + "chalk": "^4.1.2", + "create-jest-runner": "^0.12.0", + "tsd-lite": "^0.8.0" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@tsd/typescript": "4.x || 5.x" + } + }, "node_modules/jest-runner/node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -4469,12 +4539,12 @@ } }, "node_modules/jest-util": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.0.3.tgz", - "integrity": "sha512-Q0xaG3YRG8QiTC4R6fHjHQPaPpz9pJBEi0AeOE4mQh/FuWOijFjGXMMOfQEaU9i3z76cNR7FobZZUQnL6IyfdQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.3.tgz", + "integrity": "sha512-QUjna/xSy4B32fzcKTSz1w7YYzgiHrjjJjevdRf61HYk998R5vVMMNmrHESYZVDS5DSWs+1srPLPKxXPkeSDOA==", "dev": true, "dependencies": { - "@jest/types": "^29.0.3", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -4534,12 +4604,13 @@ } }, "node_modules/jest-worker": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.0.3.tgz", - "integrity": "sha512-Tl/YWUugQOjoTYwjKdfJWkSOfhufJHO5LhXTSZC3TRoQKO+fuXnZAdoXXBlpLXKGODBL3OvdUasfDD4PcMe6ng==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.4.tgz", + "integrity": "sha512-6dpvFV4WjcWbDVGgHTWo/aupl8/LbBx2NSKfiwqf79xC/yeJjKHT1+StcKy/2KTmW16hE68ccKVOtXf+WZGz7Q==", "dev": true, "dependencies": { "@types/node": "*", + "jest-util": "^29.6.3", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" }, @@ -6345,6 +6416,18 @@ "node": ">=4" } }, + "node_modules/tsd-lite": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/tsd-lite/-/tsd-lite-0.8.0.tgz", + "integrity": "sha512-wsTMCFgSs+mxM92j1G6cOSAVrwzVcqjqMwCqSs1879I18MHbJQn8IpDwr3cTN+ulTqCmfwlBpaJ4y+08JiyG5Q==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@tsd/typescript": "4.x || 5.x" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -7426,12 +7509,12 @@ } }, "@jest/schemas": { - "version": "29.0.0", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.0.0.tgz", - "integrity": "sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, "requires": { - "@sinclair/typebox": "^0.24.1" + "@sinclair/typebox": "^0.27.8" } }, "@jest/source-map": { @@ -7493,12 +7576,12 @@ } }, "@jest/types": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.0.3.tgz", - "integrity": "sha512-coBJmOQvurXjN1Hh5PzF7cmsod0zLIOXpP8KD161mqNlroMhLcwpODiEzi7ZsRl5Z/AIuxpeNm8DCl43F4kz8A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, "requires": { - "@jest/schemas": "^29.0.0", + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", @@ -7601,9 +7684,9 @@ } }, "@sinclair/typebox": { - "version": "0.24.40", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.40.tgz", - "integrity": "sha512-Xint60L8rF0+nRy+6fCjW9jQMmu7fTpbwTBrXZiK6eq/RHDJS7LvWX/0oXC8O7fCePmrY/XdfaTv2HiUDeCq4g==", + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true }, "@sinonjs/commons": { @@ -7624,6 +7707,12 @@ "@sinonjs/commons": "^1.7.0" } }, + "@tsd/typescript": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@tsd/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-VtjHPAKJqLJoHHKBDNofzvQB2+ZVxjXU/Gw6INAS9aINLQYVsxfzrQ2s84huCeYWZRTtrr7R0J7XgpZHjNwBCw==", + "dev": true + }, "@types/babel__core": { "version": "7.1.19", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz", @@ -8230,9 +8319,9 @@ "dev": true }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -8436,6 +8525,28 @@ "safe-buffer": "~5.1.1" } }, + "create-jest-runner": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/create-jest-runner/-/create-jest-runner-0.12.3.tgz", + "integrity": "sha512-xrGcSrr86F2YdbrOoAZIowSYMYBpxrOrqHEvJqIpG0vsuMVcq3+OKSe7JJR1SWJFLGiMhHInPyR48+rW9ZHq9Q==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "jest-worker": "^29.5.0", + "p-limit": "^3.1.0" + }, + "dependencies": { + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + } + } + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -9908,6 +10019,18 @@ } } }, + "jest-runner-tsd": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/jest-runner-tsd/-/jest-runner-tsd-6.0.0.tgz", + "integrity": "sha512-lSzRoVqc/AwahlKFamdwO/R63Vze/xpCnab+FsNni8zmxyBt3e3py51mFE2UQBh2gSvEYwudOSHgX+xtmLynKw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.15.8", + "chalk": "^4.1.2", + "create-jest-runner": "^0.12.0", + "tsd-lite": "^0.8.0" + } + }, "jest-runtime": { "version": "29.0.3", "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.0.3.tgz", @@ -9971,12 +10094,12 @@ } }, "jest-util": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.0.3.tgz", - "integrity": "sha512-Q0xaG3YRG8QiTC4R6fHjHQPaPpz9pJBEi0AeOE4mQh/FuWOijFjGXMMOfQEaU9i3z76cNR7FobZZUQnL6IyfdQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.3.tgz", + "integrity": "sha512-QUjna/xSy4B32fzcKTSz1w7YYzgiHrjjJjevdRf61HYk998R5vVMMNmrHESYZVDS5DSWs+1srPLPKxXPkeSDOA==", "dev": true, "requires": { - "@jest/types": "^29.0.3", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -10023,12 +10146,13 @@ } }, "jest-worker": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.0.3.tgz", - "integrity": "sha512-Tl/YWUugQOjoTYwjKdfJWkSOfhufJHO5LhXTSZC3TRoQKO+fuXnZAdoXXBlpLXKGODBL3OvdUasfDD4PcMe6ng==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.4.tgz", + "integrity": "sha512-6dpvFV4WjcWbDVGgHTWo/aupl8/LbBx2NSKfiwqf79xC/yeJjKHT1+StcKy/2KTmW16hE68ccKVOtXf+WZGz7Q==", "dev": true, "requires": { "@types/node": "*", + "jest-util": "^29.6.3", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" }, @@ -11329,6 +11453,12 @@ } } }, + "tsd-lite": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/tsd-lite/-/tsd-lite-0.8.0.tgz", + "integrity": "sha512-wsTMCFgSs+mxM92j1G6cOSAVrwzVcqjqMwCqSs1879I18MHbJQn8IpDwr3cTN+ulTqCmfwlBpaJ4y+08JiyG5Q==", + "dev": true + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", diff --git a/package.json b/package.json index de6ce03..36835eb 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "build:watch": "tsc --watch --preserveWatchOutput", "cleaner": "ts-cleaner --dist lib --watch", "test": "jest", - "test:full": "npm run build && COMPILE_EXAMPLES=1 jest", + "test:full": "npm run build && COMPILE_EXAMPLES=1 jest && npm run test:types", + "test:types": "jest --config jest.config.tsd.js", "test:watch": "jest --watch", "test:coverage": "jest --config jest.coverage.js", "test:coverage:watch": "jest --watchAll --config jest.coverage.js", @@ -33,6 +34,7 @@ }, "homepage": "https://github.com/nullishamy/args-ts#readme", "devDependencies": { + "@tsd/typescript": "^5.2.2", "@types/jest": "^29.0.3", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^5.37.0", @@ -46,6 +48,7 @@ "eslint-plugin-tsdoc": "^0.2.17", "husky": "^8.0.1", "jest": "^29.0.3", + "jest-runner-tsd": "^6.0.0", "lint-staged": "^13.0.3", "nodemon": "^2.0.20", "ts-cleaner": "^1.0.5", diff --git a/src/builder/command.ts b/src/builder/command.ts index d860793..0ba6003 100644 --- a/src/builder/command.ts +++ b/src/builder/command.ts @@ -1,8 +1,8 @@ import { Args, DefaultArgTypes } from '../args' import { CommandError } from '../error' import { InternalCommand } from '../internal/parse/types' -import { ExtractArgType } from '../internal/types' import { CommandOpts, StoredCommandOpts, defaultCommandOpts, defaultParserOpts } from '../opts' +import { ArgType } from '../util' /** * Base class for all commands, including subcommands. Any user implemented command must extend from this class. @@ -28,14 +28,14 @@ export abstract class Command { // Must use any for it to accept the subtyping this function actually performs // Black magic happens later on to extract the real subtype out of this `any` abstract args: (parser: Args) => Args - abstract run: (args: ExtractArgType>) => Promise + abstract run: (args: ArgType>) => Promise /** * Creates a runner function for use with {@link Command#run}. This exists to provide type inference to the callback, which is not available without a function call. * @param runFn - the run function * @returns - the run implementation */ - runner (runFn: (args: (ExtractArgType> & DefaultArgTypes)) => Promise): (args: ExtractArgType>) => Promise { + runner (runFn: (args: (ArgType> & DefaultArgTypes)) => Promise): (args: ArgType>) => Promise { return async (args) => await runFn(args) } diff --git a/src/internal/types.ts b/src/internal/types.ts deleted file mode 100644 index f7e7262..0000000 --- a/src/internal/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Args } from '../args' - -export type ExtractArgType = ArgObject extends Args ? TArgs : Default diff --git a/src/util/index.ts b/src/util/index.ts index 02bc60f..ecbb8b5 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -3,3 +3,4 @@ export * from './help' export * from './completion' export * from './argv' export * from './logging' +export * from './types' diff --git a/src/util/types.ts b/src/util/types.ts new file mode 100644 index 0000000..7bb8135 --- /dev/null +++ b/src/util/types.ts @@ -0,0 +1,3 @@ +import { Args } from '../args' + +export type ArgType = ArgObject extends Args ? TArgs : Default diff --git a/test/test-d/index.test-d.ts b/test/test-d/index.test-d.ts new file mode 100644 index 0000000..5a4ce41 --- /dev/null +++ b/test/test-d/index.test-d.ts @@ -0,0 +1,15 @@ +import { Args, a } from '../../src' +import { ArgType } from '../../src/util' +import { parserOpts } from '../shared' +import { expectAssignable } from 'tsd-lite' + +describe('Type testing', () => { + it('infers basic flags', () => { + const parser = new Args(parserOpts) + .arg(['--flag'], a.bool()) + + expectAssignable>({ + flag: true + }) + }) +}) diff --git a/test/test-d/util.ts b/test/test-d/util.ts new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json index f842cde..cba1f35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,7 @@ "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "lib", /* Redirect output structure to the directory. */ - "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + //"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ "removeComments": true, /* Do not emit comments to output. */