| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…`isPatternLiteralPlaceholderType`
There was a problem hiding this comment.
This PR adds support for contextual type discrimination based on template literal types. It allows template literal expressions to be used to discriminate contextual types, fixing cases where template literal expressions couldn't properly narrow union types during object literal type checking.
Key changes:
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file| File | Description |
|---|---|
| src/compiler/checker.ts | Adds contextFreeType intrinsic and updates template literal type checking logic to preserve discriminant information |
| tests/cases/conformance/types/union/discriminatedUnionTypesOverlappingDiscriminants1.ts | New comprehensive test cases for template literal discriminants in various scenarios |
| tests/cases/compiler/templateLiteralConstantEvaluation.ts | Adds test case for empty string template literal evaluation |
| tests/cases/compiler/evolvingArrayTemplateLiterals1.ts | New test for template literal behavior in evolving arrays |
| tests/cases/compiler/discriminantUsingEvaluatableTemplateExpression.ts | Adds test for evaluatable template expression discrimination |
| Various baseline files | Expected type checking results and error outputs for the new test cases |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test it |
Sorry, something went wrong.
|
Starting jobs; this comment will be updated as builds start and complete.
|
Sorry, something went wrong.
|
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
Sorry, something went wrong.
|
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing main and refs/pull/62203/merge: Everything looks good! |
Sorry, something went wrong.
|
Jake Bailey (@jakebailey)
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62203/merge: Everything looks good! |
Sorry, something went wrong.
|
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:
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Template literal types are allowed as discriminant properties since #46137
but template literal expressions can't be used to discriminate contextual types which manifests in issues like:
This PR closes the gap by preventing potential template literal types discriminants from widening to string in the context of context-free types. I don't think this changes all that much the meaning of a context-free type is. Let's consider:
The context-free type of that "_FOO" expression is a fresh "_FOO" string literal type. In the same fashion, a context-free type of a template literal expression can be that unwidened template literal type.
fixes #57231