Skip to content

Consider as const expressions as potentially context sensitive#62221

Closed
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/intra-expression-in-presence-of-as-const
Closed

Consider as const expressions as potentially context sensitive#62221
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/intra-expression-in-presence-of-as-const

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

@Andarist Andarist commented Aug 6, 2025

fixes #62220

Copilot AI review requested due to automatic review settings August 6, 2025 22:02
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Aug 6, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 6, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes TypeScript issue #62220 by making as const expressions context sensitive during type inference. The change allows the TypeScript compiler to properly infer types when as const is used in function arguments that depend on intra-expression type relationships.

Key changes:

  • Modified the isContextSensitive function in the type checker to consider as const expressions as potentially context sensitive
  • Added comprehensive test cases demonstrating the improved type inference behavior

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/compiler/checker.ts Core logic change to treat as const expressions as context sensitive when applied to context sensitive expressions
tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts Test cases showing improved type inference with as const expressions
tests/baselines/reference/intraExpressionInferences.types Updated type baselines showing more precise type inference (100 vs number)
tests/baselines/reference/intraExpressionInferences.symbols Updated symbol baselines reflecting the new test cases
tests/baselines/reference/intraExpressionInferences.js Updated JavaScript output baselines
tests/baselines/reference/intraExpressionInferences.errors.txt Updated error baselines with new test content

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 21, 2025
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

as const breaks intra expression inference

4 participants