Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect widening of literal types in emitted .d.ts for export default/export assignments, aligning tsgo’s declaration output and incremental behavior more closely with TypeScript’s (and removing previously-recorded expected diffs).
Changes:
- Preserve literal types when serializing types for
exportassignments (avoids widening1/"string"/42tonumber/string). - Adjust pseudotype literal handling to avoid forcing widening via the “big shortcut”.
- Update/clean up reference baselines and incremental test expectations now that diagnostics and signatures are correct.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/checker/nodebuilderimpl.go | Avoids widening literal types when serializing types for export assignments. |
| internal/checker/pseudotypenodebuilder.go | Stops widening for pseudotype literal mapping to prevent incorrect literal loss. |
| internal/execute/tsctests/tsc_test.go | Removes prior expectedDiff now that the underlying issue is fixed. |
| testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file.js | Baseline update: default export retains literal type; incremental diagnostics/signatures updated. |
| testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file-through-indirect-import.js | Baseline update: same as above, via re-export chain. |
| testdata/baselines/reference/tsc/composite/synthetic-jsx-import-of-ESM-module-from-CJS-module-no-crash-no-jsx-element.js | Baseline update: default export literal type preserved (42). |
| testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault(target=es2015).js | Baseline update: default export literal type preserved (12). |
| testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault(target=es2015).js.diff | Baseline diff updated to reflect convergence. |
| testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault2.js | Baseline update: default export string literal preserved ("string"). |
| testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault2.js.diff | Baseline diff removed/updated due to convergence. |
| testdata/baselines/reference/submodule/compiler/modulePreserve4.js | Baseline update: preserves 0 literals for relevant default exports. |
| testdata/baselines/reference/submodule/compiler/modulePreserve4.js.diff | Baseline diff updated to reflect convergence. |
| testdata/baselines/reference/submodule/compiler/dynamicImportsDeclaration.js | Baseline update: preserves literal defaults (0, 1, "fallback"). |
| testdata/baselines/reference/submodule/compiler/dynamicImportsDeclaration.js.diff | Baseline diff removed/updated due to convergence. |
| testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=esnext).js | Baseline update: preserves literal type in default export with JSDoc. |
| testdata/baselines/reference/compiler/jsdocCommentDefaultExport(module=commonjs).js | Baseline update: preserves literal type in default export with JSDoc. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two things:
preserveLiterals.