Skip to content

test(bundler-tests): typecheck packages under legacy module resolution - #7127

Merged
overbalance merged 1 commit into
open-telemetry:mainfrom
embrace-io:overbalance/add-legacy-ts-test
Sep 28, 2026
Merged

overbalance merged 1 commit into
open-telemetry:mainfrom
embrace-io:overbalance/add-legacy-ts-test

Conversation

@overbalance

Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

Nothing in CI typechecks the published packages the way a TypeScript consumer on "moduleResolution": "node" (node10) sees them. That mode ignores exports and imports, and is still the default for many CommonJS projects.

The packages with platform-specific code are the ones at risk. Their public entry points re-export from an internal platform module. If that re-export stops resolving under node10, TypeScript types the symbols as any. With skipLibCheck: true, which is common in consumer projects, it does so without any error. Moving platform resolution to package.json#imports (#platform) would cause exactly this regression, and nothing would catch it today.

Short description of the changes

Adds bundler-tests/node/typescript-legacy. It is a tsc --noEmit project with moduleResolution: "node" and TypeScript ~5.0.4, which is the documented minimum. It imports every public platform-specific export and asserts that none of them is any:

  • @opentelemetry/core: SDK_INFO and the four get*FromEnv helpers
  • @opentelemetry/resources: hostDetector, osDetector, processDetector and serviceInstanceIdDetector
  • @opentelemetry/sdk-trace: BatchSpanProcessor and RandomIdGenerator
  • @opentelemetry/sdk-logs: BatchLogRecordProcessor
  • @opentelemetry/instrumentation: InstrumentationBase
  • @opentelemetry/exporter-zipkin: prepareSend
  • The six OTLP http/proto exporters for logs, metrics and traces

The tsconfig sets two options explicitly:

  • skipLibCheck: false, so that an any nested inside a type (for example a constructor's config parameter) still fails the build. The top-level IsAny checks do not catch that case.
  • types: [], so that ambient @types from the monorepo root stay out of the program. A real consumer would not have them.

The project is discovered through project.json and runs in the existing bundler-tests workflow via nx run-many -t test:bundle, the same way as the webpack projects.

Type of change

This is test-only. No package code changes.

How Has This Been Tested?

  • Ran a full root npm run compile, then npm run test:bundle in bundler-tests/node/typescript-legacy. It passes on main.
  • Ran it against a build whose .d.cts files still contained unresolved from "#platform" re-exports. It fails with TS2307 in each package's dist/index.d.cts and TS2344 on every assertion.
  • Ran a scratch negative case with TypeScript 5.0.4: a fake package that re-exports from an unresolved #platform, plus a local any. Both fail the check.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@overbalance
overbalance force-pushed the overbalance/add-legacy-ts-test branch from 8aaf03e to 294b216 Compare September 27, 2026 21:58
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-28 17:21 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.77%. Comparing base (547bff4) to head (294b216).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7127   +/-   ##
=======================================
  Coverage   94.77%   94.77%           
=======================================
  Files         384      384           
  Lines       13476    13476           
  Branches     3095     3095           
=======================================
  Hits        12772    12772           
  Misses        704      704           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@overbalance
overbalance marked this pull request as ready for review September 27, 2026 22:03
@overbalance
overbalance requested review from a team as code owners September 27, 2026 22:03

@david-luna david-luna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I wonder if the minimum TS version should be bumped.

@overbalance

Copy link
Copy Markdown
Contributor Author

@david-luna According to OTel docs it should be 5.2.2 to satisfy the two year commitment

@overbalance
overbalance added this pull request to the merge queue Sep 28, 2026
Merged via the queue into open-telemetry:main with commit ee62157 Sep 28, 2026
25 checks passed
@overbalance
overbalance deleted the overbalance/add-legacy-ts-test branch September 28, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants