Files
react-native-devtools-frontend/front_end/protocol_monitor
Tim van der Lippe 3b1f7453a7 Make UIString and i18n return tagged localized strings
The LocalizedString type alias in UIString.js is a so-called
"branded type". A branded type alias allows us to construct
special types in type-casts and enforce that these specific
alias are used. The following properties hold:

1. A string can be force-casted into a LocalizedString
2. A LocalizedString can be enforced as argument type
3. A LocalizedString can be downcasted/used as regular string
4. A LocalizedString can normally not be concatenated, unless
force-casts are added (which is strongly discouraged, since
localization can be structure-dependent)

These properties are for example used to enforce that all titles
of the ViewRegistration declarations are localized strings. I have
manually verified that passing in a regular string will correctly
cause TypeScript to error.

The new i18n localization system uses the same force-cast to make
sure that the new localized strings also adhere to the same
structure.

As a result of this change, I discovered several inconsistencies
in how types were used. For example, strings were being passed
in and assumed to be localized, but not enforced. Therefore,
this CL contains several cleanups that require the LocalizedString
itself and hence have to be bundled in this CL.

R=petermarshall@chromium.org

Change-Id: I2faffde47069c900e2e5e7c0ebb460d0792d2935
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2612861
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
2021-01-08 12:39:52 +00:00
..