Now that we have so many literal types we more than ever need new syntax that would make their use natural. Please consider the following:
const value = ( true ) ; // true
const value = true ; // boolean
const value = ( 'a' ) ; // 'a'
const value = 'a' ; // string
const value = ( 1 ) ; // 1
const value = 1 ; // number
const value = [ 'a' , 1 ] ; // (string | number)[]
const value = ( [ 'a' , 1 ] ) // [string, number]
const value = ( [ ( 'a' ) , ( 1 ) ] ) // ['a', 1];
Problem:
There is no way to get a literal type value without explicit type annotation.
Solution:
Add new syntax (or shall we say some new semantics to the old mostly unused syntax)
Highlights:
Composable.
Works fine with the existing syntax, doesn't need a new one.
Highly unlikely to be a breaking change.
Doesn't affect JavaScript semantics at all, can be executed as written and will work as expected.
Shortcomings:
Undiscoverable syntax.
Semantic conflicts (breaking changes) although rare:
generated code
conditional expressions
unintended excessive syntax
Prior work:
Reactions are currently unavailable
Now that we have so many literal types we more than ever need new syntax that would make their use natural. Please consider the following:
Problem:
Solution:
Highlights:
Shortcomings:
Prior work: