How to access current scope types with `type()` / `morph()` / `narrow()` / `arrayOf()` inside scope?
How to access current scope types with
type()
/ morph()
/ narrow()
/ arrayOf()
inside scope?
1 Reply
Looks like you updated the question to include my response!
Thank you 🙂 So yes, for anyone wondering the approach @Dimava mentioned will work. It's actually one of the reasons you have to "compile" a scope in the first place.
If there weren't a compile step,
$.type
would give a "can't access property 'type' on undefined"
error since the assignment hasn't occurred yet.
This also works for recursive types somehow, e.g. this is fully inferred:
TS has definitely given up trying to resolve circular reference errors on much less convoluted cases than this, but I am glad it works 😊