This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
Add missing diagnostic context setting logic for newer js declaration emit features - #4306
Merged
Wesley Wigham (weswigham) merged 1 commit intoJun 13, 2026
Conversation
Wesley Wigham (weswigham)
requested review from
Copilot and
Jake Bailey (jakebailey)
June 13, 2026 01:53
Jake Bailey (jakebailey)
approved these changes
Jun 13, 2026
|
|
||
| ==== /index.cjs (1 errors) ==== | ||
| Object.defineProperty(exports, "api", { value: require("pkg") }); | ||
| ~~~~~ |
Member
Author
There was a problem hiding this comment.
You'll note the error actually has a sensible span, rather than being, y'know, the whole file.
Wesley Wigham (weswigham)
enabled auto-merge
June 13, 2026 01:55
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves JS declaration-emit symbol accessibility diagnostics for newer CommonJS export patterns (notably Object.defineProperty(exports, ...)) by ensuring the correct diagnostic context is set at the right time, and adds a regression test/baselines to lock in the expected error span and message.
Changes:
- Add a new compiler test case covering
Object.defineProperty(exports, "api", { value: require("pkg") })with an inaccessible type leak. - Refactor diagnostic-context setup/cleanup in the declaration transformer into a helper and apply it to additional JS emit paths.
- Introduce call-expression diagnostic-context support for the
Object.definePropertyexport pattern.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| testdata/tests/cases/compiler/cjsObjectDefinePropertyPrivateModuleDeclarationEmit.ts | New regression test for CJS Object.defineProperty(exports, ...) declaration-emit diagnostics. |
| testdata/baselines/reference/compiler/cjsObjectDefinePropertyPrivateModuleDeclarationEmit.types | New types baseline for the added test. |
| testdata/baselines/reference/compiler/cjsObjectDefinePropertyPrivateModuleDeclarationEmit.symbols | New symbols baseline for the added test. |
| testdata/baselines/reference/compiler/cjsObjectDefinePropertyPrivateModuleDeclarationEmit.errors.txt | New errors baseline asserting correct diagnostic message and span. |
| internal/transformers/declarations/util.go | Expands diagnostic-context eligibility to cover the new JS export shape (needs narrowing to bindable defineProperty calls). |
| internal/transformers/declarations/transform.go | Refactors diagnostic-context handling into setupDiagnosticContext and applies it in more JS decl-emit paths. |
| internal/transformers/declarations/diagnostics.go | Adds CallExpression diagnostic context (needs gating to avoid panics/incorrect diagnostics on non-defineProperty calls). |
Jake Bailey (jakebailey)
pushed a commit
to jakebailey/TypeScript
that referenced
this pull request
Aug 13, 2026
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preferred alternative to #3379