From e6882b7ed9a1409b02e43189871ea6399f4f46d0 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Mon, 18 Jul 2022 17:47:25 +0200 Subject: [PATCH 1/2] Update type deps Remove duplicate `long` types --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index f8a50271b..959c869ac 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", "@types/node": ">=13.7.0", "long": "^5.0.0" }, From 0e3c0ab803835eef3ea618bf429b0b25d0063938 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Thu, 21 Jul 2022 11:07:52 +0200 Subject: [PATCH 2/2] Fix type tests --- cli/package-lock.json | 11 ----------- cli/pbts.js | 2 +- index.d.ts | 2 +- package-lock.json | 11 ----------- package.json | 2 +- tests/README.md | 2 +- tests/data/convert.d.ts | 2 ++ tests/data/mapbox/vector_tile.d.ts | 2 ++ tests/data/test.d.ts | 2 ++ tsconfig.json | 3 ++- 10 files changed, 12 insertions(+), 27 deletions(-) diff --git a/cli/package-lock.json b/cli/package-lock.json index e4bfef038..07b336b7f 100644 --- a/cli/package-lock.json +++ b/cli/package-lock.json @@ -51,7 +51,6 @@ "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", "@types/node": ">=13.7.0", "long": "^5.0.0" }, @@ -741,11 +740,6 @@ "dev": true, "license": "MIT" }, - "../node_modules/@types/long": { - "version": "4.0.2", - "dev": true, - "license": "MIT" - }, "../node_modules/@types/markdown-it": { "version": "12.2.3", "dev": true, @@ -10126,7 +10120,6 @@ "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", "@types/node": ">=13.7.0", "benchmark": "^2.1.4", "browserify": "^17.0.0", @@ -10615,10 +10608,6 @@ "version": "3.0.2", "dev": true }, - "@types/long": { - "version": "4.0.2", - "dev": true - }, "@types/markdown-it": { "version": "12.2.3", "dev": true, diff --git a/cli/pbts.js b/cli/pbts.js index dd7273278..e1e003760 100644 --- a/cli/pbts.js +++ b/cli/pbts.js @@ -144,7 +144,7 @@ exports.main = function(args, callback) { var output = []; if (argv.main) output.push( - "// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'.", + "// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run build:types'.", "" ); if (argv.global) diff --git a/index.d.ts b/index.d.ts index be394f08f..3bcc2d250 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'. +// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run build:types'. export as namespace protobuf; diff --git a/package-lock.json b/package-lock.json index a6fcd8e53..8ce752da4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", "@types/node": ">=13.7.0", "long": "^5.0.0" }, @@ -738,11 +737,6 @@ "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", "dev": true }, - "node_modules/@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, "node_modules/@types/markdown-it": { "version": "12.2.3", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", @@ -10627,11 +10621,6 @@ "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", "dev": true }, - "@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, "@types/markdown-it": { "version": "12.2.3", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", diff --git a/package.json b/package.json index 959c869ac..940774585 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "prof": "node bench/prof", "test": "npm run test:sources && npm run test:types", "test:sources": "tape -r ./lib/tape-adapter tests/*.js tests/node/*.js", - "test:types": "tsc tests/comp_typescript.ts --lib es2015 --strictNullChecks --experimentalDecorators --emitDecoratorMetadata && tsc tests/data/test.js.ts --lib es2015 --noEmit --strictNullChecks && tsc tests/data/*.ts --lib es2015 --noEmit --strictNullChecks", + "test:types": "cd tests && tsc --noEmit -p ../tsconfig.json", "make": "npm run lint:sources && npm run build && npm run lint:types && node ./scripts/gentests.js && npm test" }, "dependencies": { diff --git a/tests/README.md b/tests/README.md index 783e6c6d7..b9e2eff73 100644 --- a/tests/README.md +++ b/tests/README.md @@ -5,7 +5,7 @@ It is essential that tests only use the cross-platform API that is also availabl * Use `load`, not `loadSync` * Use `Reader.create`, not `BufferReader` * Use `Writer.create`, not `BufferWriter` -* It is safe to use `Long` +* It is safe to use `Long`, but TypeScript tests must import the type from `"long"` If it's absolutely inevitable for your test case to use node-specific features, you can still use this pattern: diff --git a/tests/data/convert.d.ts b/tests/data/convert.d.ts index 17383732c..b40b881c4 100644 --- a/tests/data/convert.d.ts +++ b/tests/data/convert.d.ts @@ -1,4 +1,6 @@ import * as $protobuf from "../.."; +import Long from "long"; + export interface IMessage { stringVal?: (string|null); stringRepeated?: (string[]|null); diff --git a/tests/data/mapbox/vector_tile.d.ts b/tests/data/mapbox/vector_tile.d.ts index 382277350..c11da0697 100644 --- a/tests/data/mapbox/vector_tile.d.ts +++ b/tests/data/mapbox/vector_tile.d.ts @@ -1,4 +1,6 @@ import * as $protobuf from "../../.."; +import Long from "long"; + export namespace vector_tile { interface ITile { diff --git a/tests/data/test.d.ts b/tests/data/test.d.ts index c4bf3a71b..51c86c011 100644 --- a/tests/data/test.d.ts +++ b/tests/data/test.d.ts @@ -1,4 +1,6 @@ import * as $protobuf from "../.."; +import Long from "long"; + export namespace jspb { namespace test { diff --git a/tsconfig.json b/tsconfig.json index 22852fa67..a0b3639c2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "target": "ES5", "experimentalDecorators": true, - "emitDecoratorMetadata": true + "emitDecoratorMetadata": true, + "esModuleInterop": true, } } \ No newline at end of file