Consider as const expressions as potentially context sensitive#62221
Consider as const expressions as potentially context sensitive#62221Andarist wants to merge 1 commit intomicrosoft:mainfrom
as const expressions as potentially context sensitive#62221Conversation
There was a problem hiding this comment.
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
isContextSensitivefunction in the type checker to consideras constexpressions 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 |
|
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:
|
fixes #62220