Skip to content

Commit 5f51558

Browse files
committed
Add Type Convertion comments
1 parent f8f3e4a commit 5f51558

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/diagnostics-app/src/app/views/client-params.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import DeleteIcon from '@mui/icons-material/Delete';
1717
import AddIcon from '@mui/icons-material/Add';
1818

1919
const typeForValue = (value: unknown) => {
20+
//when using typeof arrays are "object" so we have to have this specific case
2021
if (Array.isArray(value)) return 'array';
2122
return typeof value;
2223
};
@@ -27,12 +28,14 @@ const jsonToObjectArray = (json: Object) => {
2728
const type = typeForValue(value);
2829
return {
2930
key,
31+
// Only arrays and objects need special cases here since JS will take care of the rest.
3032
value: type === 'array' || type === 'object' ? JSON.stringify(value) : value,
3133
type
3234
};
3335
});
3436
};
3537

38+
// A simple set of mappers for converting a string to the correct value for saving
3639
const CONVERTERS = {
3740
string: (v: string) => v,
3841
number: (v: string) => Number(v),
@@ -95,6 +98,7 @@ function ClientParamsPage() {
9598
sx={{ margin: '10px' }}
9699
onChange={(v: { target: { value: string } }) => changeKey(idx, v.target.value, value, type)}
97100
/>
101+
{/* TODO: Potentially add an explanation here about how users should write values for a given piece of text? */}
98102
<TextField
99103
label="Value"
100104
value={value}

0 commit comments

Comments
 (0)