From b58fdbd615d0c965aa513147dd1d1cd5addd9338 Mon Sep 17 00:00:00 2001 From: Robert Kieffer Date: Thu, 9 Jan 2025 13:45:43 -0800 Subject: [PATCH] fix: add TS unit test, pin to typescript@5.0.4 --- examples/benchmark/package.json | 2 +- examples/browser-rollup/package.json | 2 +- examples/browser-webpack/package.json | 2 +- examples/node-commonjs/package.json | 2 +- examples/node-esmodules/package.json | 2 +- examples/node-jest/package.json | 2 +- examples/node-webpack/package.json | 2 +- examples/typescript/README.md | 8 ++++++++ examples/typescript/index.ts | 3 +++ examples/typescript/package.json | 9 +++++++++ examples/typescript/tsconfig.json | 1 + package-lock.json | 16 ++++++++-------- package.json | 7 ++++--- tsconfig.base.json | 3 ++- 14 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 examples/typescript/README.md create mode 100644 examples/typescript/index.ts create mode 100644 examples/typescript/package.json create mode 100644 examples/typescript/tsconfig.json diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index a9366c65..740bae39 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "true", "start": "npm run build && npx http-server . -o", - "pretest": "HUSKY=0 npm install --no-package-lock", + "pretest": "rm -fr node_modules && npm install --no-package-lock", "test": "node node.js" }, "dependencies": { diff --git a/examples/browser-rollup/package.json b/examples/browser-rollup/package.json index c4bc11c7..c6e40a73 100644 --- a/examples/browser-rollup/package.json +++ b/examples/browser-rollup/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { - "build": "npm install --no-package-lock && rm -rf dist && rollup -c", + "build": "rm -fr node_modules && npm install --no-package-lock && rm -rf dist && rollup -c", "start": "npm run build && npx http-server . -o" }, "dependencies": { diff --git a/examples/browser-webpack/package.json b/examples/browser-webpack/package.json index c51f6b1f..07e08b5f 100644 --- a/examples/browser-webpack/package.json +++ b/examples/browser-webpack/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { - "build": "npm install --no-package-lock && rm -rf dist && webpack", + "build": "rm -fr node_modules && npm install --no-package-lock && rm -rf dist && webpack", "start": "npm run build && npx http-server . -o" }, "dependencies": { diff --git a/examples/node-commonjs/package.json b/examples/node-commonjs/package.json index 9c2f8fef..48918830 100644 --- a/examples/node-commonjs/package.json +++ b/examples/node-commonjs/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { - "pretest": "npm install --no-package-lock", + "pretest": "rm -fr node_modules && npm install --no-package-lock", "test": "node example.js" }, "dependencies": { diff --git a/examples/node-esmodules/package.json b/examples/node-esmodules/package.json index 1a997364..57ac52ad 100644 --- a/examples/node-esmodules/package.json +++ b/examples/node-esmodules/package.json @@ -5,7 +5,7 @@ "scripts": { "test:package": "( node --version | grep -vq 'v16' ) || ( node --experimental-json-modules package.mjs )", "test:example": "node example.mjs", - "pretest": "npm install --no-package-lock", + "pretest": "rm -fr node_modules && npm install --no-package-lock", "test": "npm-run-all test:*" }, "dependencies": { diff --git a/examples/node-jest/package.json b/examples/node-jest/package.json index 02973487..e884b554 100644 --- a/examples/node-jest/package.json +++ b/examples/node-jest/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { - "pretest": "npm install --no-package-lock", + "pretest": "rm -fr node_modules && npm install --no-package-lock", "test": "jest" }, "dependencies": { diff --git a/examples/node-webpack/package.json b/examples/node-webpack/package.json index c99a2269..97e4dd99 100644 --- a/examples/node-webpack/package.json +++ b/examples/node-webpack/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "rm -rf dist && webpack", - "pretest": "npm install --no-package-lock", + "pretest": "rm -fr node_modules && npm install --no-package-lock", "test": "npm run build && node dist/v1.js && node dist/v4.js && node dist/v7.js && node dist/all.js" }, "dependencies": { diff --git a/examples/typescript/README.md b/examples/typescript/README.md new file mode 100644 index 00000000..e4d47cd0 --- /dev/null +++ b/examples/typescript/README.md @@ -0,0 +1,8 @@ +# uuid test for typescript support (not really an example) + +``` +npm install +npm test +``` + +This runs `tsc` using the oldest version of TypeScript supported by this project \ No newline at end of file diff --git a/examples/typescript/index.ts b/examples/typescript/index.ts new file mode 100644 index 00000000..238f8d8e --- /dev/null +++ b/examples/typescript/index.ts @@ -0,0 +1,3 @@ +import { v4 } from 'uuid'; +// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions +v4; diff --git a/examples/typescript/package.json b/examples/typescript/package.json new file mode 100644 index 00000000..c31c9de9 --- /dev/null +++ b/examples/typescript/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "uuid": "file:../../.build/uuid.tgz" + }, + "scripts": { + "pretest": "rm -fr node_modules && npm install --no-package-lock", + "test": "npx -y --package=typescript@5.0.4 -- tsc --noEmit" + } +} diff --git a/examples/typescript/tsconfig.json b/examples/typescript/tsconfig.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/examples/typescript/tsconfig.json @@ -0,0 +1 @@ +{} diff --git a/package-lock.json b/package-lock.json index fdde9b95..475d596f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "release-please": "16.15.0", "runmd": "1.4.1", "standard-version": "9.5.0", - "typescript": "5.7.2", + "typescript": "5.0.4", "typescript-eslint": "8.18.2" } }, @@ -13534,9 +13534,9 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", - "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -13544,7 +13544,7 @@ "tsserver": "bin/tsserver" }, "engines": { - "node": ">=14.17" + "node": ">=12.20" } }, "node_modules/typescript-eslint": { @@ -23186,9 +23186,9 @@ "dev": true }, "typescript": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", - "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true }, "typescript-eslint": { diff --git a/package.json b/package.json index 292eea69..bee93c64 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "release-please": "16.15.0", "runmd": "1.4.1", "standard-version": "9.5.0", - "typescript": "5.7.2", + "typescript": "5.0.4", "typescript-eslint": "8.18.2" }, "optionalDevDependencies": { @@ -92,13 +92,14 @@ "examples:node:commonjs:test": "cd examples/node-commonjs && npm test", "examples:node:esmodules:test": "cd examples/node-esmodules && npm test", "examples:node:jest:test": "cd examples/node-jest && npm test", + "examples:node:typescript:test": "cd examples/typescript && npm test", "lint": "npm run eslint:check && npm run prettier:check", "md": "runmd --watch --output=README.md README_js.md", "prepack": "npm run build -- --no-pack", "prepare": "husky", "prepublishOnly": "npm run build", "pretest:benchmark": "npm run build", - "pretest:browser": "./scripts/iodd && npm run build && npm-run-all examples:browser:**", + "pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**", "pretest:node": "npm run build", "pretest": "npm run build", "prettier:check": "prettier --check .", @@ -106,7 +107,7 @@ "release": "standard-version --no-verify", "test:benchmark": "cd examples/benchmark && npm test", "test:browser": "wdio run ./wdio.conf.js", - "test:node": "npm-run-all examples:node:**", + "test:node": "npm-run-all --parallel examples:node:**", "test:watch": "node --test --enable-source-maps --watch dist/esm/test/*.js", "test": "node --test --enable-source-maps dist/esm/test/*.js" }, diff --git a/tsconfig.base.json b/tsconfig.base.json index e3db3ba6..9e153de8 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,5 +5,6 @@ "skipLibCheck": true, "strict": true, "target": "ES2022" - } + }, + "exclude": ["dist", "examples"] }