-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow indexing (disable type checking) on any
#743
Comments
I support this. It's very annoying to have to provide types even for things you don't care to type check for. Especially when the types you'd declare are not source of truth anyway because you are using third party code. Maybe an optional warning for traversing such "any" or "unknown" types would be useful as well |
Another potential way to frame this syntax-wise is similarly to Rust's unsafe. Make it so any type errors within |
Thank you for the feedback! A behavior similar (but not identical) to what you asked for currently exists in the The idea was that one would take their What I didn't want is to be too lenient on missing annotations, to avoid the situation you see in TypeScript where people abuse Note that in Teal, the In short, in lax mode, Teal's |
Regarding the source of truth in typing for third-party libraries, that's a common dilemma when going from untyped to typed code. The preferred approach is to declare |
I wanted to add provide a bit more context and feedback as someone looking to incorporate Teal into my existing Lua project. I recently learnt about Teal and was very excited because I had previously moved a project from Javascript to Typescript and the experience was great. However, when it comes to Teal I have greatly struggled to migrate. My sense is that Teal is not really about gradual typing as much as TS is. Requiring .lua files into .tl files practically compels you to rewrite the code unless you write a .d.tl file for every .lua file and maintain them alongside your .lua code. I really like the suggestion mentioned above for adding unsafe blocks. Probably adding a require_unsafe() to require .lua code without having to provide type annotations can also be an interesting feature. I really believe focusing on gradual typing can make it much easier for developers like me who want to bring type checking into their lua codebases. |
Disable type-checking on the
any
type, or provide another type which allows Lua-style table traversal (dynamic
?)Use-Case
Sometimes the application provides a complex hierarchy we don't want to describe with Teal records.
any
type restricts access and thetable
type only provides access one level deep.The text was updated successfully, but these errors were encountered: