[js inteorp] asA
to correspond to isA
#56957
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
web-js-interop
Issues that impact all js interop
With
isA
, I always have to end up casting to the desired type as well if I want to use members on the specifiedT
type, as we can't rely on Dart's type promotion.I've found myself wanting to add an extension method like:
So I can easily store the result without casting separately within the if.
Yes I can add this myself, but I feel this is a pretty common case, so some version of it might be useful in
dart:js_interop
(if it makes sense).tryAsA
could also work as a name if it's desired to distinguish from Dart'sas
which can throw.The text was updated successfully, but these errors were encountered: