Allow exempting parts of the program (especially external library calls) from type checking while running in checked mode #16638
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
type-enhancement
A request for a change that isn't a bug
This issue was originally filed by [email protected]
What steps will reproduce the problem?
I use a library function that has a restrictive type on its argument while in fact anything that has a socketId() method that returns something numeric would work just fine.
I like using checked mode. I feel more comfortable when the machine pays attention to what I am putting where. But I also need to pass "incompatible" objects to that method I described.
I think there is a value in something as a checked mode where things actually break as opposed to static warning in the editor which is too easy to ignore.
What is the expected output? What do you see instead?
I am asking for a mechanism that would disable a static warning in the Editor (as per Issue #4190) and also a possibility to tune the checked mode. I have the following ideas
* Have option to enable checked mode only for my code, ignoring what happens inside libraries. Possibly some annotation on library imports for selectively not checking the code being imported from that library.
Together with some mechanism (annotation?) to disable the check at the interface between my code and a library.
* Make the type system more powerful to allow expressing things like TypeA OR TypeB
* Improve type inference in the Editor. In my example in the beginning, it should be feasible to statically derive the requirement for having a socketId() method on the argument. Then even though I set up the annotation to ignore types, the Editor could warn if it is absolutely certain that the object I am passing in does not have that method and there is no way that the code will successfully execute.
The text was updated successfully, but these errors were encountered: