Skip to content

Commit a76f343

Browse files
srujzsCommit Queue
authored andcommitted
[dart:js_interop] Clean up documentation on static vs runtime guarantees
- Make clear that you shouldn't do equality checks between a Dart and JS value. - Make clear you shouldn't use `is` with JS types. - Remove mention of `as`, as that *may* be okay but is also the only way to properly cast. CoreLibraryReviewExempt: Doc-only change. Change-Id: Ie4a8f22f9c44d740ddeddab55981475f0168d25e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434760 Reviewed-by: Ömer Ağacan <[email protected]> Commit-Queue: Srujan Gaddam <[email protected]>
1 parent 5fc5f36 commit a76f343

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sdk/lib/js_interop/js_interop.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
/// and previous JavaScript interop.
2323
///
2424
/// > [!NOTE]
25-
/// > The types defined in this library only provide static guarantees.
26-
/// > The runtime types differ based on the backend, so it is important to rely
27-
/// > on static functionality like the conversion functions, for example `toJS`
28-
/// > and not runtime mechanisms like type checks (`is`) and casts (`as`).
29-
/// > Similarly, `identical` may return different results for the same JS value
30-
/// > depending on the compiler. Use `==` to check for equality of two JS types
31-
/// > instead.
25+
/// > The types defined in this library only provide static guarantees. The
26+
/// > runtime types differ based on the backend, so it is important to rely on
27+
/// > static functionality like the conversion functions. Similarly, don't rely
28+
/// > on `is` checks that involve JS types or JS-typed values. Furthermore,
29+
/// > `identical` may also return different results for the same JS value
30+
/// > depending on the compiler. Use `==` to check for equality of two JS-typed
31+
/// > values instead, but do not check for equality between a Dart value and a
32+
/// > JS-typed value.
3233
///
3334
/// {@category Web}
3435
library;

0 commit comments

Comments
 (0)