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
#126 adds allowing creating classes as a type which can be referenced
As of #126 they are treated as being nominal. Given
classX{a: number=2}
The only two cases of types where instance passes is for
constx: X=instance
is when
Type::Constant has a base type (there is a function in the code which does this) that is X. (this is because string, number and boolean are treated as special classes)
Type::Object where the information.prototype.get(object_type_id) is X
Therefore it does not perform property checks for let x: X = { a: 2 } and so will raise a type error. However it only works one way, so let x: { a: number } = new X is fine.
There is also some benefit to the variable_current_value and side effect system which means that shouldn't create to many issues. For let x: { a: number } = new X, x still has the class instance of X type as it doesn't widen.
This can simplify things. In the future:
The methods on X can be treated as a known function and therefore know the side effects (if they are already registered)
However TypeScript allows both ways. There may be a way in the future for a CLI flag to check properties (and also drop that for (x: Set<number>) => x.addx.add might not be the Set.prototype.add function)
The text was updated successfully, but these errors were encountered:
#126 adds allowing creating classes as a type which can be referenced
As of #126 they are treated as being nominal. Given
The only two cases of types where
instance
passes is foris when
Type::Constant
has a base type (there is a function in the code which does this) that isX
. (this is becausestring
,number
andboolean
are treated as special classes)Type::Object
where theinformation.prototype.get(object_type_id)
isX
Therefore it does not perform property checks for
let x: X = { a: 2 }
and so will raise a type error. However it only works one way, solet x: { a: number } = new X
is fine.This can simplify things. In the future:
However TypeScript allows both ways. There may be a way in the future for a CLI flag to check properties (and also drop that for
(x: Set<number>) => x.add
x.add
might not be theSet.prototype.add
function)The text was updated successfully, but these errors were encountered: