Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In some cases don't you need to actually execute the code to know what the type actually is. How does the type checker know then?


It doesn't. There are cases where the type-checker can't know the type (e.g. json.load has to return Any), but there are tools in the language to reduce how much that happens. If you commit to a fully strictly-typed codebase, it doesn't happen often.


You can actually annotate the return type of json.load better than that:

    JSON = float | bool | int | str | None | list[“JSON”] | dict[str, “JSON”]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: