Replace string array with enum for PreferencePaneId and add generic type to Dropdown component by besdar · Pull Request #2890 · standardnotes/app

Hi, the dropdown changes seem ok, but could you give an example in the codebase where the string array for the ids is less type-safe and maintainable?

@amanharwara, here’s an example:

-          onChange={(paneId) => {
-            selectPane(paneId as PreferencePaneId)
-          }}
+          onChange={selectPane}

In this case, the type assertion "as" is no longer needed, which enhances type safety.

Another example is here:

-     menuItems.push({ id: 'home-server', label: 'Home Server', icon: 'server', order: 5 })
+     menuItems.push({ id: PreferencePaneId.HomeServer, label: 'Home Server', icon: 'server', order: 5 })

Using an enum title provides more context in the code, as it represents a specific preference pane ID rather than just a generic string.