Suggestion: Flag unused imports after inlining platform checks
tido64 opened this issue · 0 comments
tido64 commented
import { DateTimePickerAndroid } from "@react-native-community/datetimepicker";
import { Platform } from "react-native";
export default () => {
if (Platform.OS === "android") {
return DateTimePickerAndroid.open(datePickerOptions);
} else if (Platform.OS === "ios") {
// return something iOS specific
} else {
// return something else
}
};
Metro can inline platform checks with a plugin. In the above example, targeting ios
will make DateTimePickerAndroid
unused. However, the import statement will remain and we will still import @react-native-community/datetimepicker
on iOS. There should be a way to flag this as unused on certain platforms.