Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(BSR) refactor(typescript): delete some noUncheckedIndexedAccess #7466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xlecunff-pass
Copy link
Contributor

No description provided.

Comment on lines +7 to 14
const ACCESS_FINE_LOCATION = 'android.permission.ACCESS_FINE_LOCATION'
const ACCESS_COARSE_LOCATION = 'android.permission.ACCESS_COARSE_LOCATION'

const requestGeolocPermissionSystem: AskGeolocPermission = async () => {
const permissions = await PermissionsAndroid.requestMultiple([
// @ts-expect-error: because of noUncheckedIndexedAccess
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
// @ts-expect-error: because of noUncheckedIndexedAccess
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
ACCESS_FINE_LOCATION,
ACCESS_COARSE_LOCATION,
])
Copy link
Contributor Author

@xlecunff-pass xlecunff-pass Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

le type de PermissionsAndroid.PERMISSIONS est un record qui a comme valeurs des strings (très permissif) donc on ne peut pas compter dessus pour un fort typage.

PermissionsAndroid.requestMultiple a un typage fort sur le tableau de permissions qui peut lui être passés mais ne fourni pas d'enum de ces strings :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'il serait facile, rapide et pertinent de faire une PR pour améliorer le typage de react-native ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a une possibilité de créer cet Enum dans notre projet, à voire ensuite pour la maintenabilité.
Avec la méthode ci-dessus, si une autorisation change ou n'existe plus, Typescript ne sera pas content des paramètres qui lui seront passés, même si à priori ça a l'air d'être des plain strings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je proposais de faire une PR sur le projet upstream react-native (pour faire par exemple un enum)

scripts/noUncheckedIndexedAccess_snapshot.txt Outdated Show resolved Hide resolved
@@ -111,7 +111,7 @@ export function CulturalSurveyQuestions({ route }: CulturalSurveyQuestionsProps)
const navigateToNextQuestion = () => {
if (isCurrentQuestionLastQuestion) {
postCulturalSurveyAnswers({ answers })
} else {
} else if (nextQuestion) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

il se passe quoi si isCurrentQuestionLastQuestion est falsy et que nextQuestion est aussi falsy ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rien ne se passe, le type n'autorisait pas de push une nextQuestion à undefined, il y a peut-être du métier à revoir, en cas de doute je peux revert ce code

Comment on lines +7 to 14
const ACCESS_FINE_LOCATION = 'android.permission.ACCESS_FINE_LOCATION'
const ACCESS_COARSE_LOCATION = 'android.permission.ACCESS_COARSE_LOCATION'

const requestGeolocPermissionSystem: AskGeolocPermission = async () => {
const permissions = await PermissionsAndroid.requestMultiple([
// @ts-expect-error: because of noUncheckedIndexedAccess
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
// @ts-expect-error: because of noUncheckedIndexedAccess
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
ACCESS_FINE_LOCATION,
ACCESS_COARSE_LOCATION,
])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'il serait facile, rapide et pertinent de faire une PR pour améliorer le typage de react-native ?

Copy link

sonarqubecloud bot commented Jan 2, 2025

// @ts-expect-error: because of noUncheckedIndexedAccess
isSelected={data.selectedItem === data.items[index].offerId}
onSelect={() => data.onItemSelect(item.offerId)}
isSelected={data.selectedItem === item?.offerId}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi a-t-on besoin de ce ? ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants