diff --git a/.eslintrc.cjs b/.eslintrc.cjs index da14ca18e..9342c7ee3 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -22,7 +22,9 @@ module.exports = { node: true, }, ignorePatterns: [ + "packages/typescript-compat/*/dist/**", "packages/*/dist/**", + "packages/*/.tmp/**", "node_modules/**", ], plugins: ["@typescript-eslint", "node", "import"], diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e2372bce7..cda9c72a9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,9 +12,6 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.26.1 - with: - github_token: ${{ github.token }} - name: Cache uses: actions/cache@v3 with: @@ -25,4 +22,20 @@ jobs: restore-keys: | ${{ runner.os }}-protobuf-es-ci- - name: make - run: make all checkdiff + run: make ci + typescript-compat: + runs-on: ubuntu-20.04 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/.tmp + .tmp + key: ${{ runner.os }}-protobuf-es-typescript-compat-${{ hashFiles('Makefile') }} + restore-keys: | + ${{ runner.os }}-protobuf-es-typescript-compat- + - name: make + run: make test-ts-compat diff --git a/.gitignore b/.gitignore index 33f5d7df0..5c6111fb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules /packages/*/dist +/packages/typescript-compat/*/dist /packages/protobuf-test/descriptorset.bin /packages/protoplugin-test/descriptorset.bin /.tmp diff --git a/Makefile b/Makefile index 7077cbc00..b889d4c74 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,6 @@ $(BUILD)/protobuf-conformance: $(GEN)/protobuf-conformance node_modules tsconfig @touch $(@) $(BUILD)/protobuf-example: $(BUILD)/protobuf node_modules tsconfig.base.json packages/protobuf-example/tsconfig.json $(shell find packages/protobuf-example/src -name '*.ts') - npm run -w packages/protobuf-example clean npm run -w packages/protobuf-example build @mkdir -p $(@D) @touch $(@) @@ -101,6 +100,10 @@ help: ## Describe useful make targets .PHONY: all all: build test format lint bench bootstrapwkt ## build, test, format, lint, bench, and bootstrapwkt (default) +.PHONY: ci +ci: build test-protobuf test-protoplugin test-conformance format lint bench bootstrapwkt # + $(MAKE) checkdiff + .PHONY: clean clean: ## Delete build artifacts and installed dependencies @# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs @@ -129,13 +132,8 @@ test-conformance: $(BUILD)/upstream-protobuf $(BUILD)/protobuf-conformance npm run -w packages/protobuf-conformance test .PHONY: test-ts-compat -test-ts-compat: $(GEN)/protobuf-test node_modules - @for number in $(TS_VERSIONS) ; do \ - formatted=$$(echo "$${number}" | sed -r 's/[\.]/_/g'); \ - dirname=packages/protobuf-test ; \ - echo "Testing TypeScript `node_modules/ts$$formatted/bin/tsc --version`" ; \ - node_modules/ts$$formatted/bin/tsc -p $$dirname/typescript/tsconfig.$${formatted}.json --outDir $$dirname/dist/typescript/$$formatted || exit ; \ - done +test-ts-compat: $(GEN)/protobuf-test $(BUILD)/protobuf node_modules + node packages/typescript-compat/typescript-compat.mjs .PHONY: lint lint: node_modules $(BUILD)/protobuf $(BUILD)/protobuf-test $(BUILD)/protobuf-conformance $(BUILD)/protoplugin $(GEN)/protobuf-bench $(GEN)/protobuf-example ## Lint all files diff --git a/package-lock.json b/package-lock.json index 973b280dc..484a93f06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "protobuf-es-3", + "name": "protobuf-es-2", "lockfileVersion": 3, "requires": true, "packages": { @@ -14,7 +14,8 @@ "./packages/protobuf-conformance", "./packages/protobuf-bench", "./packages/protobuf-example", - "./packages/upstream-protobuf" + "./packages/upstream-protobuf", + "./packages/typescript-compat/*" ], "dependencies": { "@typescript/vfs": "1.0.0" @@ -22,6 +23,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.11.0", "@bufbuild/license-header": "^0.0.4", + "@types/node": "^20.8.8", "@typescript-eslint/eslint-plugin": "^6.2.1", "@typescript-eslint/parser": "^6.7.3", "eslint": "^8.50.0", @@ -1263,9 +1265,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.1.tgz", - "integrity": "sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -1934,7 +1936,6 @@ "version": "20.8.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", - "dev": true, "dependencies": { "undici-types": "~5.25.1" } @@ -2678,9 +2679,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001553", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001553.tgz", - "integrity": "sha512-N0ttd6TrFfuqKNi+pMgWJTb9qrdJu4JSpgPFLe/lrD19ugC6fZgF0pUewRowDwzdDnb9V41mFcdlYgl/PyKf4A==", + "version": "1.0.30001554", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001554.tgz", + "integrity": "sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ==", "dev": true, "funding": [ { @@ -2994,9 +2995,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.565", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.565.tgz", - "integrity": "sha512-XbMoT6yIvg2xzcbs5hCADi0dXBh4//En3oFXmtPX+jiyyiCTiM9DGFT2SLottjpEs9Z8Mh8SqahbR96MaHfuSg==", + "version": "1.4.566", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.566.tgz", + "integrity": "sha512-mv+fAy27uOmTVlUULy15U3DVJ+jg+8iyKH1bpwboCRhtDC69GKf1PPTZvEIhCyDr81RFqfxZJYrbgp933a1vtg==", "dev": true }, "node_modules/emittery": { @@ -6496,135 +6497,49 @@ "typescript": ">=4.2.0" } }, - "node_modules/ts4_1_2": { - "name": "typescript", - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.2.tgz", - "integrity": "sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.1": { + "resolved": "packages/typescript-compat/v4.1.x", + "link": true }, - "node_modules/ts4_2_4": { - "name": "typescript", - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", - "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.2": { + "resolved": "packages/typescript-compat/v4.2.x", + "link": true }, - "node_modules/ts4_3_5": { - "name": "typescript", - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.3": { + "resolved": "packages/typescript-compat/v4.3.x", + "link": true }, - "node_modules/ts4_4_4": { - "name": "typescript", - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.4": { + "resolved": "packages/typescript-compat/v4.4.x", + "link": true }, - "node_modules/ts4_5_2": { - "name": "typescript", - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.5": { + "resolved": "packages/typescript-compat/v4.5.x", + "link": true }, - "node_modules/ts4_6_4": { - "name": "typescript", - "version": "4.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", - "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.6": { + "resolved": "packages/typescript-compat/v4.6.x", + "link": true }, - "node_modules/ts4_7_4": { - "name": "typescript", - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.7": { + "resolved": "packages/typescript-compat/v4.7.x", + "link": true }, - "node_modules/ts4_8_4": { - "name": "typescript", - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.8": { + "resolved": "packages/typescript-compat/v4.8.x", + "link": true }, - "node_modules/ts4_9_5": { - "name": "typescript", - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } + "node_modules/ts4.9": { + "resolved": "packages/typescript-compat/v4.9.x", + "link": true }, - "node_modules/ts5_0_4": { - "name": "typescript", - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=12.20" - } + "node_modules/ts5.0": { + "resolved": "packages/typescript-compat/v5.0.x", + "link": true + }, + "node_modules/ts5.1": { + "resolved": "packages/typescript-compat/v5.1.x", + "link": true }, "node_modules/tsconfig-paths": { "version": "3.14.2", @@ -7178,8 +7093,7 @@ "node_modules/undici-types": { "version": "5.25.3", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", - "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", - "dev": true + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" }, "node_modules/update-browserslist-db": { "version": "1.0.13", @@ -7459,27 +7373,9 @@ "@types/benchmark": "^2.1.3", "benchmark": "^2.1.4", "long": "~5.2.3", - "ts4_1_2": "npm:typescript@4.1.2", - "ts4_2_4": "npm:typescript@4.2.4", - "ts4_3_5": "npm:typescript@4.3.5", - "ts4_4_4": "npm:typescript@4.4.4", - "ts4_5_2": "npm:typescript@4.5.2", - "ts4_6_4": "npm:typescript@4.6.4", - "ts4_7_4": "npm:typescript@4.7.4", - "ts4_8_4": "npm:typescript@4.8.4", - "ts4_9_5": "npm:typescript@4.9.5", - "ts5_0_4": "npm:typescript@5.0.4" - }, - "devDependencies": { - "@types/node": "~18.11.9", "upstream-protobuf": "*" } }, - "packages/protobuf-test/node_modules/@types/node": { - "version": "18.11.19", - "dev": true, - "license": "MIT" - }, "packages/protoc-gen-es": { "name": "@bufbuild/protoc-gen-es", "version": "1.4.0", @@ -7524,6 +7420,7 @@ "@bufbuild/protobuf": "^1.4.0", "@bufbuild/protoc-gen-es": "^1.4.0", "@bufbuild/protoplugin": "^1.4.0", + "@types/node": "~20.8.6", "tsx": "^3.13.0", "typescript": "^5.2.2" } @@ -7537,14 +7434,41 @@ }, "packages/protoplugin/node_modules/@typescript/vfs": { "version": "1.5.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.5.0.tgz", + "integrity": "sha512-AJS307bPgbsZZ9ggCT3wwpg3VbTKMFNHfaY/uF0ahSkYYrPF2dSSKDNIDIQAHm9qJqbLvCsSJH7yN4Vs/CsMMg==", "dependencies": { "debug": "^4.1.1" } }, "packages/protoplugin/node_modules/typescript": { "version": "4.5.2", - "license": "Apache-2.0", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.1.x": { + "name": "ts4.1", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "18.11.9", + "typescript": "4.1.x" + } + }, + "packages/typescript-compat/v4.1.x/node_modules/@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==" + }, + "packages/typescript-compat/v4.1.x/node_modules/typescript": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.6.tgz", + "integrity": "sha512-pxnwLxeb/Z5SP80JDRzVjh58KsM6jZHRAOtTpS7sXLS4ogXNKC9ANxHHZqLLeVHZN35jCtI4JdmLLbLiC1kBow==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7553,6 +7477,216 @@ "node": ">=4.2.0" } }, + "packages/typescript-compat/v4.2.x": { + "name": "ts4.2", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "18.15.3", + "typescript": "4.2.x" + } + }, + "packages/typescript-compat/v4.2.x/node_modules/@types/node": { + "version": "18.15.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.3.tgz", + "integrity": "sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==" + }, + "packages/typescript-compat/v4.2.x/node_modules/typescript": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", + "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.3.x": { + "name": "ts4.3", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.6.0", + "typescript": "4.3.x" + } + }, + "packages/typescript-compat/v4.3.x/node_modules/@types/node": { + "version": "20.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", + "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==" + }, + "packages/typescript-compat/v4.3.x/node_modules/typescript": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.4.x": { + "name": "ts4.4", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "ts4.4", + "typescript": "4.4.x" + } + }, + "packages/typescript-compat/v4.4.x/node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.5.x": { + "name": "ts4.5", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.5.x" + } + }, + "packages/typescript-compat/v4.5.x/node_modules/typescript": { + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.6.x": { + "name": "ts4.6", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.6.x" + } + }, + "packages/typescript-compat/v4.6.x/node_modules/typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.7.x": { + "name": "ts4.7", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.7.x" + } + }, + "packages/typescript-compat/v4.7.x/node_modules/typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.8.x": { + "name": "ts4.8", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.8.x" + } + }, + "packages/typescript-compat/v4.8.x/node_modules/typescript": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v4.9.x": { + "name": "ts4.9", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.9.x" + } + }, + "packages/typescript-compat/v4.9.x/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/typescript-compat/v5.0.x": { + "name": "ts5.0", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "5.0.x" + } + }, + "packages/typescript-compat/v5.0.x/node_modules/typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + }, + "packages/typescript-compat/v5.1.x": { + "name": "ts5.1", + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "^20.8.8", + "typescript": "5.1.x" + } + }, + "packages/typescript-compat/v5.1.x/node_modules/typescript": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/upstream-protobuf": { "dependencies": { "fflate": "^0.8.1", @@ -7568,7 +7702,8 @@ }, "packages/upstream-protobuf/node_modules/fflate": { "version": "0.8.1", - "license": "MIT" + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.1.tgz", + "integrity": "sha512-/exOvEuc+/iaUm105QIiOt4LpBdMTWsXxqR0HDF35vx3fmaKzw7354gTilCh5rkzEt8WYyG//ku3h3nRmd7CHQ==" } } } diff --git a/package.json b/package.json index 81d56d832..a8397acd2 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "./packages/protobuf-conformance", "./packages/protobuf-bench", "./packages/protobuf-example", - "./packages/upstream-protobuf" + "./packages/upstream-protobuf", + "./packages/typescript-compat/*" ], "type": "module", "engineStrict": true, @@ -33,6 +34,7 @@ "eslint-plugin-node": "^11.1.0", "prettier": "^3.0.0", "typescript": "^5.2.2", + "@types/node": "^20.8.8", "@bufbuild/license-header": "^0.0.4", "jest": "^29.7.0" }, diff --git a/packages/protobuf-example/README.md b/packages/protobuf-example/README.md index 73c00bb6d..bf6321a33 100644 --- a/packages/protobuf-example/README.md +++ b/packages/protobuf-example/README.md @@ -27,23 +27,22 @@ npm run -w packages/protoplugin build npm run -w packages/protoc-gen-es build ``` -Next, `cd` into the example directory and build: +Next, `cd` into the example directory: ```shell cd packages/protobuf-example -npm run build ``` To add a person to the address book: ```shell -node dist/esm/add-person.js addressbook.bin +npm run add-person ``` To list all entries of the address book: ```shell -node dist/esm/list-people.js addressbook.bin +npm run list-people ``` ### Generate code yourself @@ -58,7 +57,5 @@ If you want to use `protoc`, the following command is equivalent: protoc -I . --es_out=src/gen --es_opt=target=ts --plugin=protoc-gen-es=./node_modules/.bin/protoc-gen-es addressbook.proto ``` -Don't forget to run `npm run build` to compile TypeScript to JavaScript, so that -Node will understand it. You do not need TypeScript to use **Protobuf-ES**. Just -set the plugin option `target=js` if you prefer plain JavaScript, or `target=js+dts` -if you prefer JavaScript with TypeScript declaration files. +You do not need TypeScript to use **Protobuf-ES**. Just set the plugin option `target=js` if you prefer plain JavaScript, +or `target=js+dts` if you prefer JavaScript with TypeScript declaration files. diff --git a/packages/protobuf-example/package.json b/packages/protobuf-example/package.json index c894dfb7c..cd5f26c4f 100644 --- a/packages/protobuf-example/package.json +++ b/packages/protobuf-example/package.json @@ -3,10 +3,9 @@ "private": true, "license": "(Apache-2.0 AND BSD-3-Clause)", "scripts": { - "clean": "rm -rf ./dist/esm/* ./dist/types/*", - "build": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/types", - "add-person": "node dist/esm/add-person.js addressbook.bin", - "list-people": "node dist/esm/list-people.js addressbook.bin", + "build": "../../node_modules/typescript/bin/tsc --noEmit", + "add-person": "tsx src/add-person.ts addressbook.bin", + "list-people": "tsx src/list-people.ts addressbook.bin", "pregenerate": "rm -rf src/gen", "generate": "buf generate" }, diff --git a/packages/protobuf-example/src/list-people.ts b/packages/protobuf-example/src/list-people.ts index 1085993a5..a5fcc06e6 100644 --- a/packages/protobuf-example/src/list-people.ts +++ b/packages/protobuf-example/src/list-people.ts @@ -55,5 +55,4 @@ function printAddressBook(addressBook: AddressBook): void { function print(line: string): void { process.stdout.write(line); process.stdout.write("\n"); - process.exit(1); } diff --git a/packages/protobuf-test/README.md b/packages/protobuf-test/README.md index 370a87a4e..d4c045673 100644 --- a/packages/protobuf-test/README.md +++ b/packages/protobuf-test/README.md @@ -13,68 +13,3 @@ from a file descriptor set. To cover the code path for our string-based fallback for 64-bit integers, the entire suite should be run with the environment variable `BUF_BIGINT_DISABLE=1`, which disables our BigInt feature detection. - -## TypeScript - -Our TypeScript compatibility tests are run by the Make target `test-ts-compat`. -Running this target will iterate over all versions specified in a sorted, -pre-configured list in the Makefile and use that version to compile protobuf-es. -If any compilation error is encountered, the process will exit immediately. - -The versions list is compiled of: - -- the earliest TypeScript version we support (4.1.2). -- the latest patch release of all minor versions up to the current release. - -Our compatibility tests use the default settings for `tsconfig.json` that are -generated by running `tsc --init` (with a few minor exceptions). As a result, -for any version we support, we inherently support the default settings -respective to that version of TypeScript. - -### Adding a new version - -The following instructions will illustrate how to add a new version to the -compatibility tests. - -For example, assuming we are adding version `4.5.3`. - -- Run the following command from the project root. This will install the -specified version of TypeScript as a package alias to `protobuf-test`. Note -that the version before the `@` sign is the version number with all decimals -replaced with underscores: - - ```bash - npm i -w packages/protobuf-test ts4_5_3@npm:typescript@4.5.3 --save-exact - ``` - -- Change directories to the TypeScript test directory: - - ```bash - cd packages/protobuf-test/typescript - ``` - -- Generate a `tsconfig.json` file by running: - - ```bash - ../../../node_modules/ts4_5_3/bin/tsc --init - ``` - -- Once generated, rename the file: - - ```bash - mv tsconfig.json tsconfig.4_5_3.json - ``` - -- Remove any extraneous comments from the file that were autogenerated. - **NOTE**: If you are adding a version after `4.5.3`, make sure to change -`skipLibCheck` to `false` in the tsconfig `compilerOptions` to test full -regressions on newer versions. - -- Add the following `include` property before the `compilerOptions`: - - ```bash - "include": ["../src/**/*"], - ``` - -- Finally, add the version to the `TS_VERSIONS` variable in the Makefile. -Make sure to add it in numerical order. diff --git a/packages/protobuf-test/package.json b/packages/protobuf-test/package.json index 8582bcf28..7c0ca0ad2 100644 --- a/packages/protobuf-test/package.json +++ b/packages/protobuf-test/package.json @@ -30,19 +30,6 @@ "@types/benchmark": "^2.1.3", "benchmark": "^2.1.4", "long": "~5.2.3", - "ts4_1_2": "npm:typescript@4.1.2", - "ts4_2_4": "npm:typescript@4.2.4", - "ts4_3_5": "npm:typescript@4.3.5", - "ts4_4_4": "npm:typescript@4.4.4", - "ts4_5_2": "npm:typescript@4.5.2", - "ts4_6_4": "npm:typescript@4.6.4", - "ts4_7_4": "npm:typescript@4.7.4", - "ts4_8_4": "npm:typescript@4.8.4", - "ts4_9_5": "npm:typescript@4.9.5", - "ts5_0_4": "npm:typescript@5.0.4" - }, - "devDependencies": { - "@types/node": "~18.11.9", "upstream-protobuf": "*" } } diff --git a/packages/protoplugin-example/package.json b/packages/protoplugin-example/package.json index 0295482b2..1bbc8e2cb 100644 --- a/packages/protoplugin-example/package.json +++ b/packages/protoplugin-example/package.json @@ -2,7 +2,6 @@ "name": "@bufbuild/protoplugin-example", "version": "1.4.0", "private": true, - "description": "", "scripts": { "build": "../../node_modules/typescript/bin/tsc --noEmit", "start": "npx esbuild src/index.ts --serve=localhost:3000 --servedir=www --outdir=www --bundle --global-name=eliza", @@ -16,7 +15,8 @@ "@bufbuild/protobuf": "^1.4.0", "@bufbuild/protoc-gen-es": "^1.4.0", "@bufbuild/protoplugin": "^1.4.0", + "typescript": "^5.2.2", "tsx": "^3.13.0", - "typescript": "^5.2.2" + "@types/node": "~20.8.6" } } diff --git a/packages/typescript-compat/README.md b/packages/typescript-compat/README.md new file mode 100644 index 000000000..a4c6b6f5f --- /dev/null +++ b/packages/typescript-compat/README.md @@ -0,0 +1,50 @@ +# TypeScript compatibility tests + +Our TypeScript compatibility tests are run by the Make target `test-ts-compat`. +Running this target will iterate over all versions specified in this directory, +and compile the TypeScript files in `packages/protobuf-test/src` with the +corresponding version of the TypeScript compiler. + +Our compatibility tests use the default settings for `tsconfig.json` that are +generated by running `tsc --init` (with a few minor exceptions). As a result, +for any version we support, we inherently support the default settings +respective to that version of TypeScript. + +### Which versions are tested + +- the earliest TypeScript version we support (4.1.2). +- the latest patch release of all minor versions up to the current release. + +### Adding a new version + +To add a new minor or major version of TypeScript to the tests, copy the directory +with the latest version, and make the following updates: + +#### package.json + +- Set an appropriate "name" field, for example `"tscompat_5.2.x"`. +- Set the version constraint for the `typescript` dependency, for example `"5.2.x"`. +- Set the version for the `@types/node` dependency. The package uses dist-tags + to tag releases for older TypeScript versions. You have to look up the + corresponding version number on https://www.npmjs.com/package/@types/node?activeTab=versions. + +Delete the `node_modules` directory in the package if it exists, and run `npm install` +from the repository root. + +#### tsconfig.json + +Generate a new `tsconfig.json` with default values with `node_modules/.bin/tsc --init`, +and merge it with the existing one: +- We want to use the default target, module, and other settings. +- We have to include the test sources. +- We explicitly want to emit declaration and declaration maps, because some + transpilation issues only occur when emitting them. +- We explicitly want to check libs. + +### Running and maintaining the tests + +Run `node packages/typescript-compat/typescript-compat.mjs` to run all tests. + +Unfortunately, `npm` has no mechanism to pin to a dist-tag for `@types/node`, +but the actual version is a moving target. It is necessary to manually verify +that we still use appropriate versions. diff --git a/packages/typescript-compat/typescript-compat.mjs b/packages/typescript-compat/typescript-compat.mjs new file mode 100644 index 000000000..49e8f14a1 --- /dev/null +++ b/packages/typescript-compat/typescript-compat.mjs @@ -0,0 +1,48 @@ +#!/usr/bin/env node + +// Copyright 2021-2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { readdirSync } from "node:fs"; +import { join as joinPath, basename } from "node:path"; +import { execSync } from "node:child_process"; +import { stdout, stderr, exit } from "node:process"; + +const typescriptCompatDir = new URL(".", import.meta.url).pathname; + +const packages = readdirSync(typescriptCompatDir, { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => joinPath(dirent.path, dirent.name)); + +for (const path of packages) { + const name = basename(path); + stdout.write(`${name} ... `); + try { + execSync("npm test", { + cwd: path, + maxBuffer: 1024 * 1024 * 10, + encoding: "utf-8", + }); + stdout.write(`OK\n`); + } catch (e) { + stdout.write(`FAILED\n`); + if (typeof e.stderr === "string") { + stderr.write(e.stderr); + } + if (typeof e.stdout === "string") { + stdout.write(e.stdout); + } + exit(1); + } +} diff --git a/packages/typescript-compat/v4.1.x/package.json b/packages/typescript-compat/v4.1.x/package.json new file mode 100644 index 000000000..cf0d2c764 --- /dev/null +++ b/packages/typescript-compat/v4.1.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.1", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "18.11.9", + "typescript": "4.1.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_1_2.json b/packages/typescript-compat/v4.1.x/tsconfig.json similarity index 83% rename from packages/protobuf-test/typescript/tsconfig.4_1_2.json rename to packages/typescript-compat/v4.1.x/tsconfig.json index f72077382..1da0a1abe 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_1_2.json +++ b/packages/typescript-compat/v4.1.x/tsconfig.json @@ -1,12 +1,12 @@ { - "include": ["../src/**/*"], + "include": ["../../protobuf-test/src/**/*"], "exclude": [ // Exclude WKTs and their usage in tests because they use syntax not // compatible with older versions of TypeScript. WKTs are typically not // generated, but imported from @bufbuild/protobuf, which is compatible. // Users of this version of TypeScript must use them. - "../src/gen/ts/google/protobuf/*.ts", - "../src/google/protobuf/*.test.ts" + "../../protobuf-test/src/gen/ts/google/protobuf/*.ts", + "../../protobuf-test/src/google/protobuf/*.test.ts" ], // These are the default compiler options for TypeScript v4.1.2, // created with `tsc --init` diff --git a/packages/typescript-compat/v4.2.x/package.json b/packages/typescript-compat/v4.2.x/package.json new file mode 100644 index 000000000..58826e6b0 --- /dev/null +++ b/packages/typescript-compat/v4.2.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.2", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "18.15.3", + "typescript": "4.2.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_2_4.json b/packages/typescript-compat/v4.2.x/tsconfig.json similarity index 83% rename from packages/protobuf-test/typescript/tsconfig.4_2_4.json rename to packages/typescript-compat/v4.2.x/tsconfig.json index 9a7304865..ece8bf1a2 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_2_4.json +++ b/packages/typescript-compat/v4.2.x/tsconfig.json @@ -1,12 +1,12 @@ { - "include": ["../src/**/*"], + "include": ["../../protobuf-test/src/**/*"], "exclude": [ // Exclude WKTs and their usage in tests because they use syntax not // compatible with older versions of TypeScript. WKTs are typically not // generated, but imported from @bufbuild/protobuf, which is compatible. // Users of this version of TypeScript must use them. - "../src/gen/ts/google/protobuf/*.ts", - "../src/google/protobuf/*.test.ts" + "../../protobuf-test/src/gen/ts/google/protobuf/*.ts", + "../../protobuf-test/src/google/protobuf/*.test.ts" ], // These are the default compiler options for TypeScript v4.2.4, // created with `tsc --init` diff --git a/packages/typescript-compat/v4.3.x/package.json b/packages/typescript-compat/v4.3.x/package.json new file mode 100644 index 000000000..8d5e9cc96 --- /dev/null +++ b/packages/typescript-compat/v4.3.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.3", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.6.0", + "typescript": "4.3.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_3_5.json b/packages/typescript-compat/v4.3.x/tsconfig.json similarity index 91% rename from packages/protobuf-test/typescript/tsconfig.4_3_5.json rename to packages/typescript-compat/v4.3.x/tsconfig.json index 91f478261..22f81bd8d 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_3_5.json +++ b/packages/typescript-compat/v4.3.x/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["../src/**/*"], + "include": ["../../protobuf-test/src/**/*"], // These are the default compiler options for TypeScript v4.3.5, // created with `tsc --init` "compilerOptions": { diff --git a/packages/typescript-compat/v4.4.x/package.json b/packages/typescript-compat/v4.4.x/package.json new file mode 100644 index 000000000..b3f1948aa --- /dev/null +++ b/packages/typescript-compat/v4.4.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.4", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "ts4.4", + "typescript": "4.4.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_4_4.json b/packages/typescript-compat/v4.4.x/tsconfig.json similarity index 68% rename from packages/protobuf-test/typescript/tsconfig.4_4_4.json rename to packages/typescript-compat/v4.4.x/tsconfig.json index 1e01736db..fa3a3fa69 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_4_4.json +++ b/packages/typescript-compat/v4.4.x/tsconfig.json @@ -1,5 +1,7 @@ { - "include": ["../src/**/*"], + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v4.4.x, created + // with `tsc --init` (except where noted in comments below) "compilerOptions": { "target": "es5", "module": "commonjs", diff --git a/packages/typescript-compat/v4.5.x/package.json b/packages/typescript-compat/v4.5.x/package.json new file mode 100644 index 000000000..d7b780272 --- /dev/null +++ b/packages/typescript-compat/v4.5.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.5", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.5.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_5_2.json b/packages/typescript-compat/v4.5.x/tsconfig.json similarity index 93% rename from packages/protobuf-test/typescript/tsconfig.4_5_2.json rename to packages/typescript-compat/v4.5.x/tsconfig.json index e540e05c2..bf55e55bc 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_5_2.json +++ b/packages/typescript-compat/v4.5.x/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["../src/**/*"], + "include": ["../../protobuf-test/src/**/*"], // These are the default compiler options for TypeScript v4.5.2, created // with `tsc --init` (except where noted in comments below) "compilerOptions": { diff --git a/packages/typescript-compat/v4.6.x/package.json b/packages/typescript-compat/v4.6.x/package.json new file mode 100644 index 000000000..dc854a10b --- /dev/null +++ b/packages/typescript-compat/v4.6.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.6", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.6.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_6_4.json b/packages/typescript-compat/v4.6.x/tsconfig.json similarity index 88% rename from packages/protobuf-test/typescript/tsconfig.4_6_4.json rename to packages/typescript-compat/v4.6.x/tsconfig.json index 6dc8c4e48..60d9d8794 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_6_4.json +++ b/packages/typescript-compat/v4.6.x/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["../src/**/*"], - // These are the default compiler options for TypeScript v4.6.4, created + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v4.6.x, created // with `tsc --init` (except where noted in comments below) "compilerOptions": { - "target": "es2016", + "target": "es5", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, diff --git a/packages/typescript-compat/v4.7.x/package.json b/packages/typescript-compat/v4.7.x/package.json new file mode 100644 index 000000000..8d7300254 --- /dev/null +++ b/packages/typescript-compat/v4.7.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.7", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.7.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_7_4.json b/packages/typescript-compat/v4.7.x/tsconfig.json similarity index 80% rename from packages/protobuf-test/typescript/tsconfig.4_7_4.json rename to packages/typescript-compat/v4.7.x/tsconfig.json index 7ff613ccc..57b4455a0 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_7_4.json +++ b/packages/typescript-compat/v4.7.x/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["../src/**/*"], - // These are the default compiler options for TypeScript v4.7.4, created + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v4.7.x, created // with `tsc --init` (except where noted in comments below) "compilerOptions": { - "target": "es2016", + "target": "es5", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, @@ -11,8 +11,6 @@ // To guard against regression and ensure we are remaining backwards // compatible, set the skipLibCheck flag to false explicitly. "skipLibCheck": false, - // To test forward-compatibility, set to NodeNext - "moduleResolution": "NodeNext", // Certain errors are only triggered by actually emitting declaration files, // see https://github.com/bufbuild/protobuf-es/pull/398 "declaration": true, diff --git a/packages/typescript-compat/v4.8.x/package.json b/packages/typescript-compat/v4.8.x/package.json new file mode 100644 index 000000000..e38654416 --- /dev/null +++ b/packages/typescript-compat/v4.8.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.8", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.8.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_8_4.json b/packages/typescript-compat/v4.8.x/tsconfig.json similarity index 80% rename from packages/protobuf-test/typescript/tsconfig.4_8_4.json rename to packages/typescript-compat/v4.8.x/tsconfig.json index d2ffd4e89..0c699769d 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_8_4.json +++ b/packages/typescript-compat/v4.8.x/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["../src/**/*"], - // These are the default compiler options for TypeScript v4.8.4, created + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v4.8.x, created // with `tsc --init` (except where noted in comments below) "compilerOptions": { - "target": "es2016", + "target": "es5", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, @@ -11,8 +11,6 @@ // To guard against regression and ensure we are remaining backwards // compatible, set the skipLibCheck flag to false explicitly. "skipLibCheck": false, - // To test forward-compatibility, set to NodeNext - "moduleResolution": "NodeNext", // Certain errors are only triggered by actually emitting declaration files, // see https://github.com/bufbuild/protobuf-es/pull/398 "declaration": true, diff --git a/packages/typescript-compat/v4.9.x/package.json b/packages/typescript-compat/v4.9.x/package.json new file mode 100644 index 000000000..c11a896ae --- /dev/null +++ b/packages/typescript-compat/v4.9.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts4.9", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "4.9.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.4_9_5.json b/packages/typescript-compat/v4.9.x/tsconfig.json similarity index 80% rename from packages/protobuf-test/typescript/tsconfig.4_9_5.json rename to packages/typescript-compat/v4.9.x/tsconfig.json index 7e51dec43..34c44a90d 100644 --- a/packages/protobuf-test/typescript/tsconfig.4_9_5.json +++ b/packages/typescript-compat/v4.9.x/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["../src/**/*"], - // These are the default compiler options for TypeScript v4.9.5, created + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v4.9.x, created // with `tsc --init` (except where noted in comments below) "compilerOptions": { - "target": "es2016", + "target": "es5", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, @@ -11,8 +11,6 @@ // To guard against regression and ensure we are remaining backwards // compatible, set the skipLibCheck flag to false explicitly. "skipLibCheck": false, - // To test forward-compatibility, set to NodeNext - "moduleResolution": "NodeNext", // Certain errors are only triggered by actually emitting declaration files, // see https://github.com/bufbuild/protobuf-es/pull/398 "declaration": true, diff --git a/packages/typescript-compat/v5.0.x/package.json b/packages/typescript-compat/v5.0.x/package.json new file mode 100644 index 000000000..53978176e --- /dev/null +++ b/packages/typescript-compat/v5.0.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts5.0", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "20.8.8", + "typescript": "5.0.x" + } +} diff --git a/packages/protobuf-test/typescript/tsconfig.5_0_4.json b/packages/typescript-compat/v5.0.x/tsconfig.json similarity index 80% rename from packages/protobuf-test/typescript/tsconfig.5_0_4.json rename to packages/typescript-compat/v5.0.x/tsconfig.json index 8352123f6..bce4ebc7b 100644 --- a/packages/protobuf-test/typescript/tsconfig.5_0_4.json +++ b/packages/typescript-compat/v5.0.x/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["../src/**/*"], - // These are the default compiler options for TypeScript v5.0.4, created + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v5.0.x, created // with `tsc --init` (except where noted in comments below) "compilerOptions": { - "target": "es2016", + "target": "es5", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, @@ -11,8 +11,6 @@ // To guard against regression and ensure we are remaining backwards // compatible, set the skipLibCheck flag to false explicitly. "skipLibCheck": false, - // To test forward-compatibility, set to NodeNext - "moduleResolution": "NodeNext", // Certain errors are only triggered by actually emitting declaration files, // see https://github.com/bufbuild/protobuf-es/pull/398 "declaration": true, diff --git a/packages/typescript-compat/v5.1.x/package.json b/packages/typescript-compat/v5.1.x/package.json new file mode 100644 index 000000000..5fce756d7 --- /dev/null +++ b/packages/typescript-compat/v5.1.x/package.json @@ -0,0 +1,11 @@ +{ + "name": "ts5.1", + "scripts": { + "test": "node_modules/.bin/tsc --outDir dist" + }, + "dependencies": { + "@bufbuild/protobuf-test": "*", + "@types/node": "^20.8.8", + "typescript": "5.1.x" + } +} diff --git a/packages/typescript-compat/v5.1.x/tsconfig.json b/packages/typescript-compat/v5.1.x/tsconfig.json new file mode 100644 index 000000000..92fcb0257 --- /dev/null +++ b/packages/typescript-compat/v5.1.x/tsconfig.json @@ -0,0 +1,19 @@ +{ + "include": ["../../protobuf-test/src/**/*"], + // These are the default compiler options for TypeScript v5.1.x, created + // with `tsc --init` (except where noted in comments below) + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + // To guard against regression and ensure we are remaining backwards + // compatible, set the skipLibCheck flag to false explicitly. + "skipLibCheck": false, + // Certain errors are only triggered by actually emitting declaration files, + // see https://github.com/bufbuild/protobuf-es/pull/398 + "declaration": true, + "declarationMap": true + } +}