Repository navigation
enable type guards over string literal types #6028
Description
Activity
- addedSuggestionAn idea for TypeScriptAn idea for TypeScriptCommittedThe team has roadmapped this issueThe team has roadmapped this issue
on Dec 10, 2015 DanielRosenwasser commented
on Dec 10, 2015 MemberMore actionsThanks for filing Aleksey-Bykov!
- addedDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefined
on Jan 4, 2016 Is this no longer intended for TypeScript 1.8?
DanielRosenwasser commented
on Jan 22, 2016 MemberMore actionsI predict that'll be going in for 2.0. We're still working on the core functionality of string literal types, and how we want things to flow throughout the type system. If we do that right, this will be much easier and might enable much more interesting features down the road.
Daniel Rosenwasser (@DanielRosenwasser) is there an issue/set of issues to track about the type system work?
zpdDG4gta8XKpMCd commented
on Jan 22, 2016 AuthorMore actionswhat are the more exciting features?
DanielRosenwasser commented
on Jan 22, 2016 MemberMore actionsDanielRosenwasser commented
on Jan 22, 2016 MemberMore actionsAleksey-Bykov basically the idea that you'd be able to not only narrow from strings to string literals, but you'd be able to use them as tags, as discussed in #1003.
zpdDG4gta8XKpMCd commented
on Jan 22, 2016 AuthorMore actionsgood, that is what this issue is about, I thought there might be more to that
Not sure if its listed anywhere, but i think this should show an error: (Hopefully in the IDE)
// declare type options = 'option1' | 'option2'; interface A { possibleOptions: options; } /// use (given class B that implements interface A) var x = new B(); if (x.possibleOptions === 'option3') { // there is no way of getting here is all possible values are either 'option1' or 'option2', should error }
DanielRosenwasser commented
on Jun 23, 2016 MemberMore actionsCan we say that this has been fixed by #9163?
zpdDG4gta8XKpMCd commented
on Jun 23, 2016 AuthorMore actionsyes, thanks
On Jun 23, 2016 02:16, "Daniel Rosenwasser" notifications@github.com
wrote:Can we say that this has been fixed by #9163
#9163?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6028 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA5PzZtK0zh11rl8vURJXL7L8VypM3hjks5qOiSfgaJpZM4GyZ6f
.- addedFixedA PR has been merged for this issueA PR has been merged for this issue
on Jun 23, 2016 - locked and limited conversation to collaborators
on Jun 19, 2018
Now that the string literal types #5185 are merged in, the type guards based on them would be an awesome addition:
by Anders Hejlsberg (@ahejlsberg):
The original issue #1003 got closed with the following comment:
A quick search suggests that there isn't a ticket for this yet. So here we go.