| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
This looks kind of untenable to review. I'm gonna rebase this so people can go commit by commit. |
Sorry, something went wrong.
All string literals will now have their types inferred as string literal types with an associated "freshness". When a string is bound to a "read-only" declaration, freshness associated with the type is lost during widening. When a string is bound to a mutable declaration, it is unconditionally widened to 'string. In any other context where widening takes place, any fresh string literal type is widened to 'string.
…at contextual typing can succeed. Fixes breakage found in 'tests/cases/fourslash/quickInfoForOverloadOnConst1.ts'
…string literal types.
…f of string literal types in unions.
…, and equality comparisons.
|
I've rebased so there are batches of commits. Here's the order
|
Sorry, something went wrong.
|
What flavor of string literal type does a string type literal introduce? Does a readonly property initialization strip a string literal of its freshness? |
Sorry, something went wrong.
Fresh. Thanks for the question, I've amended the issue.
At this point I believe that will be the case, but I will need to discuss it with Anders Hejlsberg (@ahejlsberg). |
Sorry, something went wrong.
|
This was nice to experiment with. 😃 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR changes the way in which string literal types work today. It seeks to address some of the major issues brought up in #6167. The basic gist is that all string literals start off with string literal types and are appropriately widened to string at appropriate binding locations. This widening to string occurs when the binding itself is mutable.
A alternative (and competing) approach exists on #6196, where we infer string literal types only at select locations.
Here's a small sample of the current behavior:
However, when working with a union type of string literals, we won't automatically widen to string even for a mutable binding:
Fundamental changes to string literals and string literal types are:
Changes to the widening process are as follows:
Mutability-aware widening is fairly simple:
Changes to best-common-type selection are as follows: