You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Present somehow to user that literal type is a widening literal type #11181
// File: OurCode.tsimport*astestfrom'./SomeonesLibrary'// VSCode will show:// test.a -> type: 'a' | 'b'// test.b -> type: 'a' | 'b'leta1=test.a// Type: 'a' | 'b'leta2=test.b// Type: string --->> why ??????? // not easy to answer without going to source code of someones files // to understand TS behavior// Assume user did not check what TS infered for `a1` and `a2` because // natural thinking is that it is of type `a | b`a1='c'// Throws error nicelya2='c'// No error shown
so what I'm asking is - make it more clear for user to figure out why TS behaves in a way it behaves (because right now presenting Type: a | b for both cases is misleading and can cause some bugs (or rather prevent bugs from detecting)
Maybe VSCode could show:
// test.a -> type: 'a' | 'b'// test.b -> type: widening 'a' | widening 'b' # or different color
It's not at all obvious what value this would provide -- anyone capable of understanding what that would mean probably wouldn't be confused in the first place, whereas anyone who doesn't know what widening "foo" means is going to be really lost
Activity
RyanCavanaugh commentedon Sep 27, 2016
I'm not sure this reduces net confusion, but we can consider it
RyanCavanaugh commentedon Nov 15, 2016
It's not at all obvious what value this would provide -- anyone capable of understanding what that would mean probably wouldn't be confused in the first place, whereas anyone who doesn't know what
widening "foo"means is going to be really lost