Implement any type which allows any value to be passed to it, but not the other way around. This means, unlike in TypeScript, casting any to another type will throw a compiler error if the compatibility is unknown. Since it requires knowing what the origin and destination types are, there will be compile-time checks in place to ensure type compatibility.
These checks should be done in the future using force as, matches or using typeof check to ensure the types are compatible with the operation.
Exact behaviour / changes you want
[x] Add internal any type which can be used for any value.
[x] Ensure no type allows any to be passed onto it.
Is there an existing proposal for this?
This feature does not exist in the latest version
Proposal
Implement
any
type which allows any value to be passed to it, but not the other way around. This means, unlike in TypeScript, castingany
to another type will throw a compiler error if the compatibility is unknown. Since it requires knowing what the origin and destination types are, there will be compile-time checks in place to ensure type compatibility.These checks should be done in the future using
force as
,matches
or usingtypeof
check to ensure the types are compatible with the operation.Exact behaviour / changes you want