subtypes available on scope in 2.0.0-beta.6
I have a scope defined but not seeing subtypes available
21 Replies
Hello! What exactly are you trying to achieve?
I previously had types defined as discrete type objects and was passing around references within each type, but @ssalbdivad recommended moving it to a scope where everything is inlined
and according to docs, I should be able to reference types within scope like in my first screenshot:
https://arktype.io/reference/scopes/
So you want to reuse the type from the scope inside of a derived type?
none of the types defined in the scope appear to be available on
types
objectsimplified example
The way you'd achieve that is by doing
here
example.type()
ahh so docs are out of date?
oh I see now, I missed
.export()
at the end of scope()
The docs are WIP and don't mention this functionality yet
.export()
resolved itActually they do
AFAIK, if you want to extend the scope, you instantiate it without
.export
?no clue
but for my needs, its statically defined, don't need to extend it
@PIat @frolic A scope is just like a scope in code- it's a resolution space where you can define types, generics, etc.
type
is a method of a Scope
.
Another method is called export
. That method takes all the public names in your scope, and puts them in an object called a Module
so you can access them directly
A lot of the time, if you won't need to create additional types in your scope as @PIat said, you can just export right away.
In the next release, I'm actually adding a type.module
sugar that just creates the scope and immediately exports it since it's such a common patternThank you a lot for the explanation! It sounded like straight out of the documentation 😁
Yeah I think my perfectionism gets in the way bit with docs. Some of it I just threw up there, but the stuff I consider "done" I try to think about too much
Perfectionism is so worth it when you do get to actually finish the project
Yeah it's complicated, I would not have what I have without being obsessive and perfectionistic but it's not helping anyone if I'm not publishing things that would be improvements because I'm working on bigger improvements
I think it does help
It's the principle of potential and actual value.
When a person learns many things, it's of no substance to the world yet. But as soon as they start utilizing the knowledge, it will be of much more use than if they had started working earlier, since their potential was bigger and all of a sudden exploded into merit.
Similar thing here — while you could be documenting all the features, it would take a lot of time and most importantly mental strain. The development would be slower. But now you're moving at your proper fast pace, and at the point when it'll all be done, then you'll have documentation which you're 100% sure of and it'll be a 💥
Yes I agree with all of that. I just mean in cases like the one I just explained, I'm already taking the time to answer questions explaining how stable features work, there wouldn't be any downside to just copy pasting that answer to docs TBH
True! Do it!
It'll also feel good 😋
You know, I meant it hypothetically, but I already have a scope page. I guess I will 😅