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
Is your feature request related to a problem? Please describe.
The union function today will perform a deep merge on objects, but the type system will cast the return type down to object unless every argument has a literal type. This causes errors that would be evident from manual inspection to pass unremarked by the type checker, such as:
// type: { a: 'a' }vara = { a: 'a' }
// type: { b: 'b' }varb = { b: 'b'}
// type: { a: 'a', b: 'b' }varc = union(a, b)
// the compiler will catch this and raise a diagnosticoutputc = c.cparamone { one: string }
paramtwo { two: string }
// type: objectvarthree = union(one, two)
// no diagnostic, but this will cause a runtime erroroutputthree = three.three
Describe the solution you'd like
Even with non-literal types, union(object...) could perform some inference based on its arguments. This will be rather time consuming because union(object...) performs a deep merge.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The
union
function today will perform a deep merge on objects, but the type system will cast the return type down toobject
unless every argument has a literal type. This causes errors that would be evident from manual inspection to pass unremarked by the type checker, such as:Describe the solution you'd like
Even with non-literal types,
union(object...)
could perform some inference based on its arguments. This will be rather time consuming becauseunion(object...)
performs a deep merge.The text was updated successfully, but these errors were encountered: