Repository navigation
Preserve numeric const assertion text in declarations - #64110
Draft
Jake Bailey (jakebailey) wants to merge 2 commits into
Draft
Jake Bailey (jakebailey) wants to merge 2 commits into
Jake Bailey (jakebailey) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The modified completion and hover behaviors lack required fourslash regression coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Preserves valid numeric syntax for infinite numeric literals across declaration emit, enum transforms, type display, and language-service output.
Changes:
- Emits
1e999/-1e999instead of shadowableInfinity. - Preserves source spelling for directly const-asserted numeric literals.
- Adds compiler tests and updates affected baselines.
File summaries
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/fakeInfinity2.ts |
Tests shadowed Infinity with enum emit. |
tsc/testdata/tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts |
Tests numeric const declaration emit. |
tsc/testdata/tests/cases/compiler/constEnumInfinityShadow.ts |
Tests const-enum inlining with shadowing. |
tsc/testdata/baselines/reference/conformance/octalIntegerLiteralES6.types |
Updates infinite octal type display. |
tsc/testdata/baselines/reference/conformance/octalIntegerLiteral(target=es2015).types |
Updates ES2015 octal display. |
tsc/testdata/baselines/reference/conformance/enumConstantMembers.js |
Updates infinite enum emit. |
tsc/testdata/baselines/reference/conformance/binaryIntegerLiteralES6.types |
Updates infinite binary type display. |
tsc/testdata/baselines/reference/conformance/binaryIntegerLiteral(target=es2015).types |
Updates ES2015 binary display. |
tsc/testdata/baselines/reference/compiler/fakeInfinity3.types |
Updates inferred infinite types. |
tsc/testdata/baselines/reference/compiler/fakeInfinity3.js |
Verifies shadow-safe declarations and emit. |
tsc/testdata/baselines/reference/compiler/fakeInfinity2.types |
Updates types and added enum coverage. |
tsc/testdata/baselines/reference/compiler/fakeInfinity2.symbols |
Records added test symbols. |
tsc/testdata/baselines/reference/compiler/fakeInfinity2.js |
Verifies shadow-safe enum output. |
tsc/testdata/baselines/reference/compiler/fakeInfinity1.types |
Updates infinite literal type formatting. |
tsc/testdata/baselines/reference/compiler/fakeInfinity1.errors.txt |
Updates diagnostic type spelling. |
tsc/testdata/baselines/reference/compiler/deferredConditionalTypes2.types |
Updates conditional-type displays. |
tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types |
Records inferred numeric types. |
tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.symbols |
Records regression-test symbols. |
tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js |
Verifies declaration spelling preservation. |
tsc/testdata/baselines/reference/compiler/declarationEmitEnumNaN.js |
Updates infinite enum declarations. |
tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types |
Records const-enum inferred types. |
tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.symbols |
Records const-enum symbols. |
tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js |
Verifies shadow-safe const-enum inlining. |
tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.errors.txt |
Records expected non-finite diagnostic. |
tsc/internal/transformers/tstransforms/utilities.go |
Emits overflow numeric literals for infinity. |
tsc/internal/transformers/inliners/constenum.go |
Makes const-enum inlining shadow-safe. |
tsc/internal/transformers/declarations/transform.go |
Makes enum declaration emit shadow-safe. |
tsc/internal/ls/completions.go |
Formats infinite exhaustive-case snippets. |
tsc/internal/jsnum/string.go |
Defines canonical infinity literal text. |
tsc/internal/checker/pseudotypenodebuilder.go |
Restores const-assertion source spelling. |
tsc/internal/checker/nodecopy.go |
Preserves overflowing computed-name text. |
tsc/internal/checker/nodebuilderimpl.go |
Emits valid infinite literal type nodes. |
tsc/internal/checker/nodebuilder_hover.go |
Formats infinite enum hover initializers. |
tsc/internal/checker/emitresolver.go |
Emits shadow-safe literal constants. |
Review details
- Files reviewed: 34/34 changed files
- Comments generated: 2
- Review effort level: Balanced
Comment on lines
+104
to
+108
| if v.IsInf() { | ||
| if v < 0 { | ||
| return b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(jsnum.InfinityLiteralText, 0)) | ||
| } | ||
| return b.f.NewNumericLiteral(jsnum.InfinityLiteralText, 0) |
Comment on lines
+6639
to
+6642
| text := v.Abs().String() | ||
| if v.IsInf() { | ||
| text = jsnum.InfinityLiteralText | ||
| } |
Preserve original numeric text when reusable and use 1e999 as a valid infinity spelling for synthesized types, declarations, enum output, completions, and hover.
Jake Bailey (jakebailey)
force-pushed
the
fix-63831
branch
from
October 7, 2026 22:31
43d984b to
4328695
Compare
This branch has not been deployed
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.

Fixes #63831