feat(http-client-python): migrate eng scripts from tsx to native Node.js TypeScript - #11425
feat(http-client-python): migrate eng scripts from tsx to native Node.js TypeScript#11425Timothee Guerin (timotheeguerin) with Copilot wants to merge 11 commits into
Conversation
…js TypeScript Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Python emitter diffBaseline No changes to generated output. Rendered diff: inline on the run summary, or the emitter-diff-html artifact. Informational check (eng/emitter-diff); does not block the PR. |
|
Copilot the build is failing did you check it was passing? |
…atibility Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
... Fixed in the latest commit. The root cause: Node.js native type stripping doesn't do import elision — it strips type annotations but leaves import statements untouched.
|
|
Copilot still failing pm install typespec-http-client-python-0.35.0.tgz |
…modules type stripping - Create eng/scripts/setup/install-runner.js and prepare-runner.js as plain JavaScript bootstrappers that work in any Node.js context (including under node_modules where type stripping is not allowed) - Create eng/scripts/setup/tsconfig.build.json to compile setup scripts to dist/scripts/setup/ using rewriteRelativeImportExtensions so .ts imports become .js in the compiled output - Update package.json: install/prepare lifecycle scripts use the .js runners; build step now also compiles setup scripts to dist/ Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Fixed in the latest commit. Root cause: Node.js 22+ native TypeScript type stripping is explicitly disabled for files under Fix:
|
|
Copilot still failing the build 29:5 warning Unexpected console statement no-console /mnt/vss/_work/1/s/packages/http-client-python/eng/scripts/setup/prepare-runner.js ✖ 2 problems (0 errors, 2 warnings) ESLint found too many warnings (maximum: 0). === Linting Python Generator (pygen) === [RUN] /mnt/vss/_work/1/s/packages/http-client-python/venv/bin/python -m pylint generator/pygen --rcfile=eng/scripts/ci/config/pylintrc --recursive=y --py-version=3.10 Your code has been rated at 10.00/10 [PASS] /mnt/vss/_work/1/s/packages/http-client-python/venv/bin/python completed successfully ##[error]PowerShell e |
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Fixed — added |
commit: |
|
Copilot still failing DO test the FULL build locally and make sure it passes also pull main and merge conflicts |
…tive-node-typescript # Conflicts: # packages/http-client-python/package.json Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
There was a problem hiding this comment.
Yuchao Yan (@msyyc) I was not super sure about the way it was done in the packaged instance
There was a problem hiding this comment.
iscai-msft / Libba Lawrence (@l0lawrence) for awareness
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot could we change what file gets called with publishConfig overrides?
There was a problem hiding this comment.
I looked into it — publishConfig can't do this with npm.
- npm's
publishConfigonly holds npm config values (registry/tag/access/provenance/etc.), not package.json field overrides:lib/commands/publish.jsjust doesflatten(manifest.publishConfig, opts)into the npm config. Arbitrary field overrides (main,exports,scripts, …) are a pnpm/yarn feature, and even pnpm's allowlist doesn't includescripts. - I also confirmed empirically that
npm packdoes not rewritepackage.jsonfrompublishConfig— the tarball's manifest keeps the originalscripts. SinceBuild-Packages.ps1packs withnpm packand thennpm install <tgz>, the packedinstall/preparescripts are exactly what's in the repo'spackage.json. This package is also excluded from the pnpm workspace, so pnpm's publish rewriting doesn't apply either.
So the entry file has to be one that works in both contexts, which is why the *-runner.js bootstraps exist (.ts can't be type-stripped under node_modules).
If the runners feel too magic, the alternative I'd suggest is dropping TypeScript for the lifecycle chain entirely — convert eng/scripts/setup/{install,prepare,run-python3,system-requirements}.ts to plain .js. That removes both runners plus the extra tsconfig.build.json/tsc build step, at the cost of losing types in those ~340 lines. Happy to do that if you prefer it — just let me know.
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
|
All changed packages have been documented.
Show changes
|
| "./dist/emitter/pyodide-loader.js": "./dist/emitter/pyodide-loader.browser.js" | ||
| }, | ||
| "engines": { | ||
| "node": ">=22.0.0" |
|
Copilot resolve the merge conflicts in this pull request |
|
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Merged Two conflicting files, both from main splitting type imports onto their own lines:
Verified both files parse/execute under Node's native type stripping. |
There was a problem hiding this comment.
🟢 Approval recommended
The migration is internally consistent and preserves installed-package lifecycle behavior through compiled fallbacks.
Review details
Files not reviewed (1)
- packages/http-client-python/package-lock.json: Generated file
- Files reviewed: 14/15 changed files
- Comments generated: 0 new
- Review effort level: Balanced

Mirrors the change from Azure/typespec-azure#5068: replace
tsxas the TypeScript script runner with Node.js native TypeScript support (Node 22+ strips types natively).Changes
package.json: Replace alltsx ./eng/scripts/...invocations withnode ./eng/scripts/...; removetsxfromdependencieseng/scripts/setup/*.tsandeng/scripts/ci/regenerate.ts: Change relative imports from.js→.tsextensions (required for native Node TS resolution)tsx <script>.tsusage examples tonode <script>.ts