-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
mojo-null.patch
60 lines (51 loc) · 2.15 KB
/
mojo-null.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
commit a29a47989e76d7f13d7080819152e6d9976f01bf
Author: rbpotter <[email protected]>
Date: Wed Feb 28 23:21:01 2024 +0000
WebUI TypeScript Mojo bindings: Update type definitions to match runtime
At runtime, nullable struct fields are set to null, not to undefined.
Update the type annotation to match. i.e.:
Previously:
interface Foo {
x?: string,
}
After this CL, this becomes
interface Foo {
x: (string|null),
}
Note: also investigated changing the runtime behavior to not
populate optional struct fields when they are set to null (which
indicates they are unset). This would be more intuitive from the
perspective of Chromium TypeScript development (i.e., would not
require explicitly setting null as is done in this CL). However,
this modification appears to break some assumptions in Blink, so
is likely infeasible at least for the short term. See
https://chromium-review.googlesource.com/c/chromium/src/+/5280348
Bug: 1442785, 1293911
Change-Id: I63b422236a1947abc0a225ec3983c9619bdf72e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5269917
Reviewed-by: Demetrios Papadopoulos <[email protected]>
Commit-Queue: Rebekah Potter <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1266707}
diff --git a/content/test/data/web_ui_mojo_ts_test.ts b/content/test/data/web_ui_mojo_ts_test.ts
index 4a0b3246e6b01..35ec8d674ed66 100644
--- a/content/test/data/web_ui_mojo_ts_test.ts
+++ b/content/test/data/web_ui_mojo_ts_test.ts
@@ -38,7 +38,7 @@ async function doTest(): Promise<boolean> {
{
const testStruct: OptionalNumericsStruct = {
optionalBool: true,
- optionalUint8: undefined,
+ optionalUint8: null,
optionalEnum: TestEnum.kOne,
};
@@ -65,9 +65,9 @@ async function doTest(): Promise<boolean> {
}
{
const testStruct: OptionalNumericsStruct = {
- optionalBool: undefined,
+ optionalBool: null,
optionalUint8: 1,
- optionalEnum: undefined,
+ optionalEnum: null,
};
const {optionalBool, optionalUint8, optionalEnum, optionalNumerics} =