Closed johnynek closed 6 months ago
Is there something else I need to do make that type name available?
Use StarlarkValueAsType to define global with type symbol.
Overall, typechecking documentation is heavily outdated. For example, if you start using this symbol in function signatures, it will be runtime typechecking, but static typechecking is turned off by default.
Thank you for the reply.
After your comment I found this code as a good example to learn from:
Thanks again. I'm unblocked.
Thanks for this great library and the documentation.
I have been working on some example configuration tooling based on this library and I would like to have typechecking working for my particular dialect of starlark.
Taking as an example your
complex
type here:https://docs.rs/starlark/latest/starlark/#defining-rust-objects-that-are-used-from-starlark
I tried to implement something similar to Label in the standard bazel starlark:
I would have thought that
type = Label
would have allowed me to useLabel
in typechecking:but I get an error like:
error: Variable
Labelnot found
Is there something else I need to do make that type name available? If I remove the type ascription then everything I am doing works, so I'm wiring up my functions correctly.
Rather than debug my particular example, another possible solution to this issue would be to make your
complex
example work with typechecking so that your newly introduced type could be referenced in type annotations.Thank you!