'return': conversion from 'int' to 'uint8_t', possible loss of data in CSSHexColor (#52496)

Summary:
Resolves https://github.com/microsoft/react-native-windows/issues/14666
We faced this issue while integrating [0.79.0-nightly-20250220-41b597c73](https://github.com/microsoft/react-native-windows/pull/14662/files#top)

This warning is treated as error and should be fixed here as well.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[GENERAL] [FIXED] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/52496

Test Plan:
Fixed error:
##[error]node_modules\react-native\ReactCommon\react\renderer\css\CSSHexColor.h(39,12): Error C4244: 'return': conversion from 'int' to 'uint8_t', possible loss of data
2>D:\a_work\1\s\node_modules\react-native\ReactCommon\react\renderer\css\CSSHexColor.h(39,12): error C4244: 'return': conversion from 'int' to 'uint8_t', possible loss of data [D:\a_work\1\s\vnext\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
(compiling source file '../../node_modules/react-native/ReactCommon/react/renderer/components/view/BaseViewProps.cpp')

Tested E2E in RNW

Reviewed By: javache

Differential Revision: D78000818

Pulled By: rshest

fbshipit-source-id: 5caafc5e92540f722b009480f030276e526355af
This commit is contained in:
Anupriya Verma
2025-07-09 05:05:52 -07:00
committed by Facebook GitHub Bot
parent 47957f9adc
commit 2ca88a0069
@@ -34,9 +34,9 @@ constexpr uint8_t hexToNumeric(std::string_view hex, HexColorType hexType) {
}
if (hexType == HexColorType::Short) {
return result * 16 + result;
return static_cast<uint8_t>(result * 16 + result);
} else {
return result;
return static_cast<uint8_t>(result);
}
}