From 8483c05dcf82e552a29ac569812a12f7e63cba81 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Wed, 25 Sep 2024 20:31:39 +0100 Subject: [PATCH] chore: add TS --- .gitignore | 3 +- package-lock.json | 56 +++++++++++++++++++++++++++++++++++++- package.json | 5 +++- {lib => src}/containers.js | 0 {lib => src}/files.js | 0 {lib => src}/index.js | 0 {lib => src}/platform.js | 2 +- {lib => src}/specs.js | 0 {lib => src}/types.js | 2 +- {lib => src}/utils.js | 0 tsconfig.json | 11 ++++++++ 11 files changed, 74 insertions(+), 5 deletions(-) rename {lib => src}/containers.js (100%) rename {lib => src}/files.js (100%) rename {lib => src}/index.js (100%) rename {lib => src}/platform.js (99%) rename {lib => src}/specs.js (100%) rename {lib => src}/types.js (99%) rename {lib => src}/utils.js (100%) create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index aa292fa9..55d5773b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .nyc_output -dist \ No newline at end of file +dist +lib \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e795dc5a..44974985 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,13 @@ "version": "6.0.0-rc.1", "license": "MIT", "devDependencies": { + "@types/node": "^22.7.1", "benchmark": "~2.1.4", "eslint": "^8.30.0", "mocha": "^10.2.0", "nyc": "~15.0.0", - "tmp": "^0.1.0" + "tmp": "^0.1.0", + "typescript": "^5.6.2" }, "engines": { "node": ">=6.0.0" @@ -437,6 +439,16 @@ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "node_modules/@types/node": { + "version": "22.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.1.tgz", + "integrity": "sha512-adOMRLVmleuWs/5V/w5/l7o0chDK/az+5ncCsIapTKogsu/3MVWvSgP58qVTXi5IwpfGt8pMobNq9rOWtJyu5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, "node_modules/acorn": { "version": "8.8.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", @@ -3022,6 +3034,27 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -3647,6 +3680,15 @@ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "@types/node": { + "version": "22.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.1.tgz", + "integrity": "sha512-adOMRLVmleuWs/5V/w5/l7o0chDK/az+5ncCsIapTKogsu/3MVWvSgP58qVTXi5IwpfGt8pMobNq9rOWtJyu5Q==", + "dev": true, + "requires": { + "undici-types": "~6.19.2" + } + }, "acorn": { "version": "8.8.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", @@ -5591,6 +5633,18 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true + }, + "undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", diff --git a/package.json b/package.json index 95ea28e0..8d4ef31b 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "node": ">=6.0.0" }, "scripts": { + "prepublish": "tsc", "clean": "rm -rf coverage node_modules", "cover": "nyc mocha -- --ui tdd", "lint": "eslint etc/ lib/ test/ \"etc/scripts/**\"", @@ -50,11 +51,13 @@ "test": "mocha --ui tdd --reporter dot" }, "devDependencies": { + "@types/node": "^22.7.1", "benchmark": "~2.1.4", "eslint": "^8.30.0", "mocha": "^10.2.0", "nyc": "~15.0.0", - "tmp": "^0.1.0" + "tmp": "^0.1.0", + "typescript": "^5.6.2" }, "author": { "name": "Matthieu Monsch", diff --git a/lib/containers.js b/src/containers.js similarity index 100% rename from lib/containers.js rename to src/containers.js diff --git a/lib/files.js b/src/files.js similarity index 100% rename from lib/files.js rename to src/files.js diff --git a/lib/index.js b/src/index.js similarity index 100% rename from lib/index.js rename to src/index.js diff --git a/lib/platform.js b/src/platform.js similarity index 99% rename from lib/platform.js rename to src/platform.js index d94ec18c..00d0747c 100644 --- a/lib/platform.js +++ b/src/platform.js @@ -18,4 +18,4 @@ function getHash(str, algorithm) { module.exports = { getHash, debuglog: util.debuglog -}; +}; \ No newline at end of file diff --git a/lib/specs.js b/src/specs.js similarity index 100% rename from lib/specs.js rename to src/specs.js diff --git a/lib/types.js b/src/types.js similarity index 99% rename from lib/types.js rename to src/types.js index 1594e71d..19b5096f 100644 --- a/lib/types.js +++ b/src/types.js @@ -3015,7 +3015,7 @@ function isJsonBuffer(obj) { * * @param path {Array} Passed from hook, but unused (because empty where this * function is used, since we aren't keeping track of it for effiency). - * @param val {...} The object to reject. + * @param val {any} The object to reject. * @param type {Type} The type to check against. * * This method is mostly used from `_write` to signal an invalid object for a diff --git a/lib/utils.js b/src/utils.js similarity index 100% rename from lib/utils.js rename to src/utils.js diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..55aa06e6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "./lib", + "allowJs": true, + "target": "es5", + "strict": true + }, + "include": [ + "./src/**/*" + ] +} \ No newline at end of file